With this library you can use Discourse as a SSO provider for your Spring (Boot) application.
The Discourse SSO provider is described on meta.discourse.org.
Discourse SSO provider must be enabled and configured with a (site specific) secret inside the admin settings.
- Redirect to
DISCOURSE_ROOT_URL/session/sso_provider?sso=PAYLOAD&sig=SIGNATURE, wheressois a Base64 & URL encoded payload consisting of anonceand areturn_sso_urlsigis a HMAC-SHA256 signature of the Base64 encoded payload
- Login procedure or instant redirect from Discourse to the
return_sso_url - Validate and process response parameters
ssoandsig- Compute signature of
ssoand compare withsig - Validate
sso.nonce - Create Spring Security Authentication from
ssopayload
- Compute signature of
This project comes with AutoConfiguration support.
- Add
spring-discourse-sso-autoconfiguredependency:
<dependency>
<groupId>org.ollide</groupId>
<artifactId>spring-discourse-sso-autoconfigure</artifactId>
<version>CURRENT_RELEASE</version>
</dependency>
- Configure
spring-discourse-ssoinside yourapplication.properties:
discourse.sso.secret=***************
discourse.sso.discourseUrl=https://<<DISCOURSE_DOMAIN>>/session/sso_provider
-
Optional customizations:
-
The application's login endpoint defaults to
/login/discourseand can be customized with the propertydiscourse.sso.loginPath -
The
return_sso_urldefaults to/login/discourse/successand can be customized with the propertydiscourse.sso.returnPath
-
If you don't want to use AutoConfiguration support, you must use
spring-discourse-sso directly:
<dependency>
<groupId>org.ollide</groupId>
<artifactId>spring-discourse-sso</artifactId>
<version>CURRENT_RELEASE</version>
</dependency>
The key components to look for are:
DiscourseSigner: Takes the SSO secret, signs & validates the payloadsSsoEndpoint: Triggers the redirect to DiscourseDiscourseSsoVerificationFilter: ServletFilter for the response, validates and attempts authenticationDiscoursePrincipal: The Principal that can be accessed through Spring's SecurityContext after successful authentication
