Discourse SSO with OAuth2

AI-generated summary

The discussion revolves around setting up Single Sign-On (SSO) with OAuth2 between a website and Discourse, both using GitHub OAuth. arivanandan wants users logging in to their website via GitHub to be automatically signed in to Discourse, where comments are embedded.

arivanandan clarifies that both the website and Discourse use GitHub OAuth exclusively, and the goal is to link the two so that a user authenticated via GitHub OAuth on the website is also logged into Discourse.

itsbhanusharma explains that the authentication process only occurs between the website and GitHub, and that a mechanism is needed to notify Discourse of the user’s login status. Two possible solutions are using Discourse as the SSO server or finding a way to enqueue Discourse login alongside the website login.

arivanandan eventually finds a potential solution using the discourse-jwt plugin, which supports JWT authentication, as their auth plugin already provides a JWT.

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?

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:

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.