Quick Start
Last updated
Was this helpful?
Was this helpful?
moduleSettings = {
"cbsso" : {
"providers" : [
{
type: "GitHubProvider@cbsso",
clientId: getJavaSystem().getProperty( "GITHUB_CLIENT_ID" ),
clientSecret: getJavaSystem().getProperty( "GITHUB_CLIENT_SECRET" )
}
]
}
};public void function CBSSOAuthorization( event, data ){
// the provider that was used for SSO
var provider = data.provider;
// an instance of ISSOAuthorizationResponse that contains our data
var ssoAuthorizationResponse = data.ssoAuthorizationResponse;
if( !ssoAuthorizationResponse.wasSuccessful() ){
logger.error( "Failed SSO workflow: #ssoAuthorizationResponse.getErrorMessage()#" );
relocate( "/login" );
}
var user = UserService.findByEmail( ssoAuthorizationResponse.getEmail() );
// check if we have a user record for this person already
if( isNull( user ) ){
user = UserService.new();
user.setEmail( ssoAuthorizationResponse.getEmail() );
user.setFirstName( ssoAuthorizationResponse.getFirstName() );
user.setLastName( ssoAuthorizationResponse.getLastName() );
user.save();
}
// log them in - YAY SSO!
user.login();
relocate( "/dashboard" );
} <!-- in views/login.cfm -->
<cfoutput>
<cfscript>
providerOptions = getInstance( "ProviderService@cbsso" ).getProviderOptions();
</cfscript>
<form action="/login">
<h2>Login</h2>
<input name="username" type="text" />
<input name="password" type="password" />
<button type="submit">Submit</button>
</form>
<p>-- or --</p>
<div>
<!-- Loop through our providers and use the provided URL to start SSO -->
<cfloop array="#providerOptions#" index="option" />
<a class="link-button" href="#option.url#">Continue with #option.name#</a>
</cfloop>
</div>
</cfoutput>