Skip to content

Instantly share code, notes, and snippets.

@chrisscott
Last active April 4, 2019 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisscott/4d5f349f0723b656bb225a9254c5c50f to your computer and use it in GitHub Desktop.
Save chrisscott/4d5f349f0723b656bb225a9254c5c50f to your computer and use it in GitHub Desktop.
Auth0 Rule - Add claim to a token
function (user, context, callback) {
// Roles should only be set to verified users.
if (!user.email || !user.email_verified) {
return callback(null, user, context);
}
if (user.app_metadata.drupal_role) {
context.idToken['https://example.com/drupal_role'] = user.app_metadata.drupal_role;
}
callback(null, user, context);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment