BoxLang 🚀 A New JVM Dynamic Language Learn More...
This extension provides single sign on API for Preside applications using a simple and secure technique with easy to follow implementation details for client applications.
IT REQUIRES PRESIDE 10.9 AND ABOVE
Install the extension to your application via either of the methods detailed below (Git submodule / CommandBox).
From the root of your application, type the following command:
box install preside-ext-simple-sso-idp
From the root of your application, type the following command:
git submodule add https://github.com/pixl8/preside-ext-simple-sso-idp.git application/extensions/preside-ext-simple-sso-idp
The extension provides nothing more than a service layer API to generate one-time tokens for use with a SSO request to your external client. Configuration of your external client is, for now, left entirely to you.
SSO flow is as follows:
/sso/clientx/
event.accessDenied( reason="LOGIN_REQUIRED" )
SimpleSsoService.createToken()
yoursite.com/api/simplesso/v1/user/{token}/
, where {token}
is the token passed in step 4.At /handlers/Sso.cfc
:
component {
// inject simpleSsoService that is provided by the extension
property name="simpleSsoService" inject="simpleSsoService";
public void function clientx( event, rc, prc ) {
// login check
if ( !isLoggedIn() ) {
event.accessDenied( reason="LOGIN_REQUIRED" );
}
// get configured client endpoint for external system
var clientXEndpoint = getSystemSetting( "clientx", "sso_endpoint" );
// generate a one time SSO token and create a query string
var qs = "token=" & simpleSsoService.createToken();
// add query string to endpoint
clientXEndpoint &= ( clientXEndpoint.find( '?' ) ? "&" : "?" ) & qs;
// redirect user to endpoint, including token in query string
setNextEvent( url=clientXEndpoint );
}
}
The following is an overly simplified example for demonstration purposes.
token = url.token ?: "";
http url="https://authprovider.site.com/api/simplesso/v1/user/#token#" username=apiSecretToken {}
userDetails = DeSerializeJson( cfhttp.fileContent );
// use userDetails to sign in...
Firstly, ensure that you are running Preside 10.9 or above. Next, you need to ensure that you have the REST API manager enabled by adding the following line to your Config.cfc
file:
settings.features.apiManager.enabled = true;
Next, login to the Preside admin and navigate to System -> API Manager. Here you can create API users and grant them access to the /simplesso/v1
API. Each client application will get a generated token with which to authenticate - this will need to be supplied to external teams.
Join the Preside team Slack where we'll be happy to help with any issues or unclear instructions.
$
box install preside-ext-simple-sso-idp