Integrating OpenAthens Keystone with Auth0
Create the OpenAthens Application Record:
First set up a basic application record in Keystone as per Quickstart for OpenAthens Keystone. You’ll need to enter a placeholder for the redirect URI to get it set up - you’ll update that later with value Auth0 will generate.
Hop into the connection that was created and turn on the rule called Shortened OIDC subject (52 characters) and save.
Return to the application configuration tab as you’ll need the client ID and client Secret in the next step…
Within the Auth0 Dashboard
Authentication > Social
Create Connection
Choose Create Custom (last option)
Fill out the details
The name will be displayed to users when the login method is enabled
Authorization URL: https://connect.openathens.net/oidc/auth
Token URL: https://connect.openathens.net/oidc/token
Scope: openid
ClientID: from the SP dashboard or your notes
Client Secret: From the SP dashboard or your notes
Fetch User Profile Script: You need a script here to reach the OpenAthens userinfo endpoint and extract any user claims you need. At the very least you will need the scope and targetedID. Something like this bare minimum example derived from docs https://auth0.com/docs/authenticate/identity-providers/social-identity-providers/oauth2?&_ga=2.259469198.564227038.1582657563-2146598467.1582657563#fetch-user-profile-script
JSfunction(access_token, ctx, callback) { const request = require('request'); const userinfoEndpoint = "https://connect.test.openathens.net/oidc/userinfo"; request.get(userinfoEndpoint, { 'headers': { 'Authorization': 'Bearer ' + access_token } }, function(error, resp, body) { if (error) { return callback(error); } else if (resp.statusCode !== 200) { return callback(new Error(body)); } else { const response = JSON.parse(body); const profile = { "user_id": response.eduPersonTargetedID, "targetedID": response.eduPersonTargetedID, "eduPersonScopedAffiliation": response.eduPersonScopedAffiliation }; callback(null, profile); } }); }
Save changes
Move on to Auth Pipeline > rules
Create
Add an empty rule.
The rule needs to pass the claims you have obtained from OpenAthens into the response Auth0 sends to your local client. Something like:
JSfunction (user, context, callback) { context.idToken["http://uniquenamespace/eduPersonScopedAffiliation"] = user.eduPersonScopedAffiliation; context.idToken["http://uniquenamespace/targetedID"] = user.targetedID; callback(null, user, context); }
Users should now be able to select OpenAthens and Authenticate. When they return to your site, you should be able to authorise using the claims that you receive.