Hello, I’m trying to get an account’s roles and permissions then add them to idToken as custom claims. But it seems like I missed something or misconfigured so authorization extension doesn’t work as I expected. Please help
What I’ve done:
-
Create an API named ‘New API’. A machine-to-machine app was also created automatically after this step.
-
Define scopes of New API, including ‘read:data’, ‘create:data’, ‘delete:data’.
-
Install authorization extension.
-
Create permissions with names exactly same as scope names in step 2
-
Create role ‘New API Manager’ with all 3 permissions created in step 4.
-
Create a group named ‘KMS’.
-
Add an user to role ‘New API manager’ and group ‘KMS’
-
In Authorization configuration, enable token contents ‘groups’, ‘roles’, ‘permissions’. Then Publish Rule
-
Add new rule with following code:
function (user, context, callback) {
const namespace = ‘https://new-api.com/’;
context.idToken[namespace + ‘permissions’] = user.permissions;
context.idToken[namespace + ‘groups’] = user.groups;
console.log(user);
callback(null, user, context);
} -
When I try to login with the user in step 7, I check the rule log in ‘Debug rule’, and here’s the information. The question is why am I only receiving ‘groups’, while ‘roles’ and ‘permissions’ fields are empty arrays
Here’s the user I logged in
Here’s the idToken payload