Send Auth0 roles for role mapping
Add an Auth0 Action that puts the user's roles in the ID token under a namespaced claim, then map that claim to abilities in Workforce Intelligence.
Auth0 does not put roles or groups in an ID token on its own. It also silently drops a custom
claim whose name is not a namespaced URL, so a claim named plain groups or roles never
reaches Workforce Intelligence. Two things fix this: an Action that sets the claim, and a
namespaced claim name that you enter in Claim name.
You need the admin ability in Workforce Intelligence and access to your Auth0 tenant.
1. Create the application#
- In the Auth0 Dashboard, create an application of type Regular Web Application.
- Under Settings, add the OIDC redirect URI from the Single sign-on page (it ends in
/auth/callback) to Allowed Callback URLs. - Note the Client ID and Client Secret, and your tenant's domain.
The Issuer you enter in Workforce Intelligence is https://<your-tenant-domain>/. Auth0
includes a trailing slash in its issuer, and the value must match the provider's discovery
document exactly, so include it.
2. Create roles and assign them#
Under User Management > Roles, create a role for each group of people you want to
map, for example wi-admins, and assign it to users. The Action below sends the names of the
roles a user holds.
3. Add the Action#
-
Open Actions > Library, select Build Custom, name it, for example "Send roles to Workforce Intelligence", and choose the Login / Post Login trigger.
-
Replace the code with the following. Change
namespaceto a URL you control, such as your Workforce Intelligence address. It is only a label, and it does not have to resolve.exports.onExecutePostLogin = async (event, api) => { const namespace = "https://wi.company.com"; const roles = (event.authorization && event.authorization.roles) || []; api.idToken.setCustomClaim(`${namespace}/groups`, roles); }; -
Select Deploy.
-
Open Actions > Flows > Login, drag the Action from Custom into the flow between Start and Complete, and select Apply.
An Action does nothing until it is both deployed and placed in the flow.
4. Configure Workforce Intelligence#
- On the Single sign-on page, add the domain as OpenID Connect (OIDC) with the Issuer, Client ID and Client secret from Auth0.
- Set Claim name to the exact claim you created:
https://wi.company.com/groupsin the example. When you set a name, only that exact name is read; the defaultrolesandgroupsare not checked. Set it when you add the domain, or select Edit later. - Select Edit mapping, add a row for each role, with the role's name as the value, and pick its ability.
Check that it works#
Sign in as a user who holds a mapped role. Mapped abilities apply from that sign-in.
- To see what Auth0 sends, decode the ID token and look for the namespaced claim.
- If the abilities do not change, confirm that Claim name matches the namespaced name character for character and that the Action is in the Login flow.
- The email must be verified in Auth0 for sign-in to succeed.