I recently created an app that has two methods of logging in: one is Auth0’s passwordless mechanism and the other is using our company’s Okta instance. I’m currently using this Login Flow to attach roles to the Auth0 id tokens which works for when we create users in the Auth0 admin console, but I don’t want to do this for our Okta users which already have role information in their user profile.
Ideally, I would use the code provided in the Auth0 docs as a flow and set the roles I find in the okta token in the auth0 idtoken:
exports.onExecutePostLogin = async (event, api) => {
const namespace = 'https://my-app.example.com';
if (event.authorization) {
if (event.connection == 'okta') {
*/ use okta token to get roles attached to okta user /*
api.idToken.setCustomClaim(`${namespace}/roles`, {{roles_from_okta}});
api.accessToken.setCustomClaim(`${namespace}/roles`, {{roles_from_okta}});
}
api.idToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
api.accessToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
}
}
Is the okta token exposed to this api? I wasn’t able to find this info in the docs.