Handling The Identity Provider Response
While most identity providers follow similar protocols there is room for each one to provide slightly different workflows. Some providers use SAML, some use oAuth. And even if two providers use the same protocol there may be variation in how they use or present different pieces of information.
Part of cbSSO's goal is to help hide as much of these implementation details as possible. To accomplish this, we have created the cbsso.models.ISSOAuthorizationResponse interface and have provided an implementation as well.
Reading the response
Every provider returns an ISSOAuthorizationResponse. In addition to the common typed fields such as getName(), getEmail(), getFirstName(), getLastName(), and getUserId(), the response exposes the provider's complete claim set:
getClaims()returns a struct keyed by the claim name. Every value is an array so multi-valued SAML attributes are preserved.getClaim( name, defaultValue )returns the first value for a claim, or the supplied default.getNameId()returns the SAML subjectNameID, when one is present.getNameIdFormat()returns theNameIDformat. Check this before treating a SAMLNameIDas a portable identifier; some formats are scoped to a single application registration or session.
For example:
var response = data.ssoAuthorizationResponse;
if ( response.wasSuccessful() ) {
var claims = response.getClaims();
var groups = structKeyExists( claims, "http://schemas.microsoft.com/ws/2008/06/identity/claims/groups" )
? claims[ "http://schemas.microsoft.com/ws/2008/06/identity/claims/groups" ]
: [];
logger.info( "Signed in #response.getEmail()# with #groups.len()# group claim value(s)" );
}For MicrosoftSAMLProvider, these values come only from the signed assertion that passed validation. Do not use getRawResponseData() as a source of identity claims.
After a SSO workflow has been initiated eventually the identity provider will respond to the initiating application. The format of the response varies by provider. To handle the responses each provider implements a method (processAuthorizationEvent )that will take the response, parse it, transform it into an ISSOAuthorizationResponse and return it to your app for further processing.
Handling The ISSOAuthorizationResponse
Once a response has been received and parsed cbSSO fires of the CBSSOAuthorization event. One way you could handle this event would be
Behind The Scenes
Unless you implement a custom provider you shouldn't need to worry to much about how the SSO responses are handled. That being said, here is an example that shows how the GitHub provider implements this processAuthorizationEvent( required any event ) method.
Last updated
Was this helpful?