Discourse SSO with OAuth2

I’d like to set up SSO with github OAuth. When the user logs in to my site via github, it should also sign them in to discourse. Discourse comments are embedded on the site.

How do I go about this?

2 Likes

For OAuth2 connection to your own site, you could use this plugin

“Login with GitHub” is built-in to discourse, and you can find setup instructions here:

4 Likes

I’m still confused.

In case it wasn’t clear, I have

Website with Github OAuth.
Discourse with Github OAuth.

Neither of them have any other login methods.
When a user logs in to my website, they should be logged into discourse as well.

What I’m missing is the link between them. How do I log them into discourse when they authenticate via Github OAuth on my website?

When someone logs into Your website, the only talking that happens is in between GitHub and your website.

I.e.
Your website calls github to ask if a user exists in their user database
Github responds yes (or no) and returns user data or authentication token as requested by your site.
Now, the user gets logged in to your site.

There is no play of discourse here in the equation. What you need here is some way to tell discourse that the given user has just logged in and needs to be logged into discourse as well.

What You need is a way to enqueue discourse login along with your website login so that discourse knows when a user has logged in/out.

Auth0 does this pretty well out of the box…
Another way is to use discourse as your SSO server.

Thanks for the replies!

I figured the auth plugin I use actually runs though OAuth and gives a JWT. The discourse-jwt thing should work for me I think.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.