Magnify's SSO API enables you to implement single-sign-on using your existing user database and web login forms, by defining a secure mechanism for sharing information between your web server and Magnify.
This API enables Magnify's servers to check with your server to confirm whether a visitor has already authenticated themselves. (It's important to note that the direction of the API calls used here are from Magnify's servers to yours, the reverse of the the Channel Access API, which allows your servers to make calls in to Magnify.)
The following general requirements describe the circumstances intended for use of the SSO API.
Use of the SSO API involves passing some type of token between your main web site and your Magnify site, whether by cookie or by redirect. The token is treated as an opaque value, so you can use any format you'd like, including a random number, a session ID, a short text string, or any similar value, as long as you can later use that value to determine whether the user has identified themselves.
After the token has been exchanged, the Magnify server then makes a server-to-server request, passing the token back to your validation script, and receiving the corresponding user information. That user information is then added to the user database on your Magnify site, and associated with the current visitor's session.
Activation of the SSO mechanism consists of the following steps:
The Magnify SSO API supports two different ways of obtaining an authentication token for users:
Each of these approaches is described further below.
This diagram shows some of the typical interaction flows in the cookie mode:
These additional technical requirements must be addressed to implement the Cookie authentication mode.
This system should work with any type of cookie lifecycle, including the following:
To configure your Magnify site to retrieve these cookies, you will need to enter the following parameters:
This diagram shows some of the typical interaction flows in the redirect token mode:
To configure the Redirect Token mode you will need to configure an additional script on your server that will generate authentication tokens and include them in a redirect URL.
To configure your Magnify site to call your token-generation script, you will need to enter the following parameters:
If your token generation service will only be used by Magnify, you can enhance its security by refusing requests if the redirect target URL does not correspond to your channel's web address.
To avoid replay attacks that might allow a malicious visitor to gain access to other user accounts, we recommend enabling digital signature validation for these redirects.
It is required that your login and logout scripts redirect to /login/sso on your Magnify site.
Timestamps are simply the number of seconds since 1/1/1970. If you are using a Unix-based machine, this is what the time function returns natively.
Digital signatures are created with the md5 hashing function. Take the query string that has been created up to that point, append your secret key, determine the md5 hash signature of that entire string, then append that signature to the query string and return it.
Configure the External Token Source section of the SSO Configuration page as follows:
Validation type: External Redirecthttps://www.yoursecuresite.com/ssoscripts/checkIdentity?method=verify&key=yesitreallyisme&want_signature=true&redirect=$SITE?user_id=${response/user_id}
Signature and timestamp values:
signature MYSECRETHASHKEY tsAdditionally, the first part of the Parameter Name entry, below in the Token Validation section, would be user_id.
Based on the configuration above, you would get the request to verify the currently logged in user. For your response, you would start by creating your query string with the user id to be returned and the timestamp:
user_id=100&ts=1256910447Create your signing string by adding your secret key onto the end:
user_id=100&ts=1256910447MYSECRETHASHKEYTake the md5 hash of that signing string, ff00d451cf8616ae7d7e964ba9cc3816, and use it to sign the query string:
user_id=100&ts=1256910447&signature=ff00d451cf8616ae7d7e964ba9cc3816With that query string, redirect the browser to the following based on the redirect in the test page URL:
http://www.yourmagnifysite.com/login/sso?user_id=100&ts=1256910447&signature=ff00d451cf8616ae7d7e964ba9cc3816
Regardless of whether you're using cookies or redirects, both approaches require a script or web-accessible function on your server to be able to validate the cookie or token value. It is important to note that even if you are using redirects, this call is made directly to your server from the Magnify servers and no redirect is used.
When your Magnify channel site receives a web request with a new value for the authentication cookie or token, it sends that value to your validation script.
If the authentication cookie or token is invalid, or it isn't associated with an active user, your script should return an empty response.
If the authentication cookie is valid and corresponds to an active user in your system your script should respond with information about that user.
To configure your Magnify site to call your validation script, you will need to enter the following parameters:
Your script is expected to return the variables that you have specified above.
https://secure.yoursite.com/sso/validateValidation Call Style
POST - Form Parameter - Raw FormParameter Name
user_id&method=getUserInfo&key=yesitreallyisme&login=mylogin&password=mypasswordReturn Value Mapping:
external_nid,id,email,email,handle,name/first name/last,thumbnail_url,photo
The magnify server would send the request to your script with your ID that we need information about as the value for the first key in the Parameter Name field (user_id in this case) and the rest of the pairs exactly as entered. If, as above, you have requested a POST, the key/value pairs are sent as POST data, not as a query string.
The user data can be returned in one of two different formats:
In either format, the following fields can be provided:
external_nid (required)handle (required)email (required)namethumbnail_urlAn example XML return value for the above Return Value Mapping is shown below. An xml header line of some sort must be included to tell our system that you are returning xml. Note the use of / and space to combine return xml fields.
<?xml version="1.0" encoding="UTF-8"?> <userinfo> <id>123</id> <handle>JDoe</handle> <email>j.doe@gmail.com</email> <name> <first>John</first> <last>Doe</last> </name> <photo>http://myserver.com/photos/jdoe.jpeg</photo> </userinfo>
An example query-string (not exactly for this example) encoded return value is shown below:
id=123&handle=JDoe&email=j.doe@gmail.com&name=John%20Doe&photo=http://myserver.com/photos/jdoe.jpegThe Return Value Mapping for this query string would be:
external_nid,id,email,email,handle,name,thumbnail_url,photoIf your validation service will only be used by Magnify, you can enhance its security by refusing requests unless they originate from IP addresses associated with Magnify's servers, currently located at 208.70.246.82, 208.70.246.58, 208.70.246.67, 208.70.246.167 and 208.70.246.187. If you are using redirects, this restriction must only be for the vaidation service and not for the redirect calls, as they will come from the user's browser.
Magnify's servers may cache validation results for a moderate amount of time, such as fifteen minutes. However, if we receive a request that requires authentication, and the previous validation result was not authenticated, we will re-check the validation before sending the user to your login page.
When incorporating the results of the validation call into our user database, if there isn't a user entry with the given external nid, we check to see if there's a user with no ID and the provided email address, so user accounts created before the SSO feature was enabled will be automatically merged with the new SSO information.
The following configuration parameters are required:
The following configuration parameters are optional:
More information on these parameters is available on the configuration reference page.