How can I make Discourse use Asp.Net Core 3.1 webapp as an Identity Provider

AI-generated summary

DotNetCoder is trying to configure an Asp.Net Core 3.1 web app with Identity as an Identity Provider for a Discourse forum. The goal is to maintain the user store in the web app, allowing Discourse to authenticate users through the app. If a user is signed in to the web app, they should be automatically signed in to Discourse.

The process appears to involve setting up Identity Server 4 on the web app and then either using Discourse’s built-in SSO functionality or installing an OAuth2 plugin. farhanalie is facing a similar issue and is seeking input from DotNetCoder on how to proceed.

Here’s the problem I’m trying to solve:

  1. I have an Asp.net Core 3.1 web app with Identity (not Identity Server - yet) running at beta.example.com. Users can register, create profiles, sign in with Google/FB, etc. Bog standard ASP.net Authentication/Authorization, no real modifications to the code.
  2. I also have a Discourse forum running under a subdomain (forumbeta.example.com).

I would like the user store to be maintained in the dotnet core app. The app will be the Identity Provider. When a user tries to sign in to Discourse, discourse should ask the web app for the user’s info (name, email, possibly other attributes). If the user exists in the web app and is already signed in, discourse should sign the user into Discourse and allow them to post. If the user doesn’t exist or isn’t signed in, they should get redirected to the app’s signin/register page and either create an account or sign up - and then get redirected back to discourse.

I’ve been doing a lot of reading on the subject, and it appears that I need to install and set up Identity Server 4 on the dotnet app, which will enable it to be an Identity Provider. Then, apparently, I either need to

  1. Use Discourse’s inbuilt SSO functionality
    OR
  2. Install an Oauth2 plugin into Discourse and then configure it

I’m somewhat lost at this point and would love some experienced help to tell me how to proceed. The information on the web is somewhat outdated and I don’t want to spend hours going down a blind alley.

@DotNetCoder Did you have any luck? I’m into a similar problem. I would love your input on this.