I have an Okta Workforce Identity Cloud Enterprise Connection. I have turned on Sync Users and Groups Using SCIM. Everything is working great, except for Enterprise Groups > Roles assignment.
My Okta Enterprise Groups appear correctly under the Enterprise Groups page. I also see all the members in my groups, so that works perfectly. I then assigned a Role to an enterprise group. However, my Post Login Action Trigger is unable to access those roles. It feels like this might be a bug within Auth0 platform.
I am fetching the roles like this:
const roles = [...(event.authorization?.roles ?? [])];
When I output the roles in the debug panel like this:
console.log("Auth0 Roles:", roles);
The role from the Enterprise Group is missing. Am I wrong to expect the Role assigned to the Enterprise Group to appear here? How can I get access to those assigned roles?
Hi @iris-technology
Welcome to the Auth0 Community!
You are asking how to correct the Post-Login Action guidance for your Okta Workforce Enterprise connection, so that group information from Okta is available to your Action and is not confused with Auth0 RBAC roles.
Summary: Group membership from Okta reaches Auth0 only when the Okta application sends a groups claim, and Auth0 stores that value as federated_groups on the user, which is separate from the RBAC roles returned in event.authorization.roles.
Root Cause: Auth0 can receive group values from Okta only if the Okta application includes a groups claim in the ID token. When the claim is missing or filtered out, the user record does not contain federated_groups, even though the connection mapping lists it. Group membership and Auth0 RBAC roles are also separate objects, so a role assigned to a group does not automatically appear in event.authorization.roles.
Solution: Confirm that Okta sends the groups claim, then read federated_groups from the user in your Action.
- Open the Okta application that connects to Auth0, then select the Sign On tab.
- Edit the OpenID Connect ID Token settings, and set the Group Claims Filter to the name
groups.
- Select the Matches regex option and enter
.* to return all groups. If the regex option returns no groups in your Okta organization, change the filter to an expression such as Groups.startsWith("your_prefix", "", 100).
- Sign in through the Okta connection again, then check the user's raw JSON in the Auth0 Dashboard for a
federated_groups value.
- Read the
federated_groups value in your Post-Login Action. The value arrives as a string, so split it on the delimiter your Okta filter uses before you compare individual groups.
- Map any group that must grant access to an Auth0 role in a separate step, using the Management API call described in the earlier guidance. Federated group values alone do not add RBAC roles.
Just so we are on the same page, I am referring to this new feature under “User Management” titled “Enterprise Groups (New)”.
My enterprise groups are showing up. When I select an enterprise group, I am shown a page to assign roles. When I assign the role, it all works correctly. When I look at a user in the enterprise group, they are automatically assigned the role because they are in the group.
However, that role is not coming through in the event.authorization.roles which seems really strange to me. It looks like the user has the role in the portal, why wouldn’t it come through?
Just so we are on the same page, I am referring to the new feature under “User Management” titled “Enterprise Groups (New)”.
When I assign the role to the group, it all works as expected. When I look at a user in the enterprise group, they are automatically assigned the role because they are in the group.
However, that role is not coming through in the event.authorization.roles. It looks like the user has the role in the portal, why wouldn’t it come through?
Hi again.
Thanks for providing more information on the matter, indeed, it appears I misunderstood the question at hand.
[Summarry]
This is expected behavior. In Auth0 Post-Login Actions, event.authorization.roles only populates roles that are assigned directly to the user profile.
Roles inherited indirectly via Enterprise Groups (synced via SCIM) are not merged into event.authorization.roles during the action pipeline.
[Solution]
To access the user’s complete set of roles—including both direct assignments and group-inherited roles—query the Effective Roles endpoint from the Auth0 Management API:
GET /api/v2/users/{user_id}/effective-roles
This endpoint returns direct roles as well as roles inherited through groups (identified by the sources field in the response).
[Example on fetching the roles inside a Post-Login Action]
-
In your Action editor, add the auth0 npm package dependency (version ^4.0.0 or later).
-
Configure your Action secrets (e.g., M2M_DOMAIN, M2M_CLIENT_ID, M2M_CLIENT_SECRET) with credentials for a Machine-to-Machine application authorized for the Auth0 Management API with the read:users scope.
-
Fetch the effective roles:
const { ManagementClient } = require('auth0');
/**
* Handler that will be called during the execution of a PostLogin flow.
*
* @param {Event} event - Details about the user and the context of the authentication transaction.
* @param {PostLoginAPI} api - Interface for modifying the authentication flow.
*/
exports.onExecutePostLogin = async (event, api) => {
const management = new ManagementClient({
domain: event.secrets.M2M_DOMAIN,
clientId: event.secrets.M2M_CLIENT_ID,
clientSecret: event.secrets.M2M_CLIENT_SECRET,
});
try {
// Fetch effective roles (direct + Enterprise Group inherited roles)
const response = await management.users.getEffectiveRoles({
id: event.user.user_id,
});
const effectiveRoles = response.data.map((r) => r.name);
console.log("Auth0 Effective Roles:", effectiveRoles);
// If you need to include them in the ID or Access Token:
const namespace = 'https://your-app.example.com';
api.idToken.setCustomClaim(`${namespace}/roles`, effectiveRoles);
api.accessToken.setCustomClaim(`${namespace}/roles`, effectiveRoles);
} catch (error) {
console.error("Error fetching effective roles:", error);
}
};
Hope this clarifies everything and if you have any other questions, let me know!
Kind Regards,
Nik