IdentityServer integration w/ Discourse
This sample extends IdentityServer3 with endpoints enabling SSO with a Discourse instance.
Discourse supports direct integration with Twitter, Yahoo, Google, but not a generic OpenId Connect Provider like IdentityServer3.
- Enable SSO in Discourse
- Create custom endpoints integrating with IdentityServer3
1. How to setup Discourse for custom SSO:
Go to your discourse instance as an admin at
/admin/site_settings/category/login, and enable SSO:
For more information, see Discourse own docs about this.
These endpoints handle the communication between Discourse and IdentityServer3. Discourse initiates a login session by providing a payload that can be validated by using the secret and SHA256.
By using running in the idsrv pipeline,
/core, we can use IdentityServer extension methods on the current context.
Here, we're using the
GetIdentityServerFullLoginAsync() extension. If idsrv says there is an authenticated user, we redirect back
to Discource with the custom response it needs to login a user in Discourse. Otherwise, we show a login form.