Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@saltukalakus
Created April 24, 2019 20:30
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 saltukalakus/2d8396eb87799b35b89fecfd00274e77 to your computer and use it in GitHub Desktop.
Save saltukalakus/2d8396eb87799b35b89fecfd00274e77 to your computer and use it in GitHub Desktop.
Insert the groups which starts with a case insensitive keyword into the ID token with an Auth0 rule
function (user, context, callback) {
const namespace = 'https://acme.com/';
const KEY_WORD = "ruler"; // Any groups which start with Ruler is inserted.
function selectGroups(group) {
return group.toLowerCase().indexOf(KEY_WORD) === 0;
}
context.idToken[namespace + 'groups'] = user.groups &&
user.groups.filter(selectGroups);
callback(null, user, context);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment