Entra ID Groups Claim Overage
Goal
When mapping Entra ID security groups to DynamoAI roles, users who belong to many groups in Microsoft Entra ID may sign in successfully but not receive the org-level roles you configured with Advanced Claim to Role mappers. This guide explains why that happens, how to confirm it, and how to fix it.
This issue affects deployments that use Advanced Claim to Role mappers keyed on the groups claim. Deployments that use a single Hardcoded Role mapper for every IdP user are not affected.
Background
How group-based mappers work
During IdP brokering, Keycloak reads claims from the ID token Entra ID returns and evaluates each Advanced Claim to Role mapper against the groups claim. If a mapper's regex matches one of the group Object IDs in that claim, Keycloak assigns the corresponding DynamoAI role.
This flow is documented in Adding Mappers — Mapping Entra ID Security Groups to DynamoAI Roles. It assumes the ID token always contains a groups array with the security group Object IDs you mapped.
Entra ID group limits in tokens
Microsoft Entra ID caps how many groups it embeds directly in a JWT:
| Token type | Group limit |
|---|---|
| JWT (ID or access token) | 200 groups |
| SAML | 150 groups |
| Implicit flow (ID token only) | 6 groups |
When a user belongs to more groups than the limit, or when the token would exceed size limits, Entra ID omits the groups claim entirely. Instead, the token may include an overage indicator that tells the receiving application to query Microsoft Graph for the user's full group membership:
{
"_claim_names": {
"groups": "src1"
},
"_claim_sources": {
"src1": {
"endpoint": "https://graph.microsoft.com/v1.0/users/{user-id}/getMemberObjects"
}
}
}
For implicit-flow tokens, the overage indicator is a hasgroups: true claim instead of _claim_names.
See Configure group claims for applications and Access token claims reference — groups for Microsoft's documentation on this behavior.
Why Keycloak mappers fail
Keycloak's IdP mappers evaluate claims present in the ID token at login time. They do not follow _claim_sources endpoints or call Microsoft Graph on your behalf.
When the groups claim is missing:
- Advanced Claim to Role mappers find nothing to match.
- The user still receives the hardcoded
all-usersgroup mapper (if configured). - The user does not receive org-level roles tied to Entra group membership.
From the user's perspective, sign-in succeeds but access looks wrong — similar to a permissions problem, but the root cause is a missing claim in the upstream token, not incorrect Keycloak configuration.
A user with no groups claim in the token may still belong to dozens or hundreds of Entra groups. Always investigate overage before concluding the user is not in the mapped group.
Symptoms
Users affected by group overage typically show this pattern:
- Sign-in through Entra ID completes without error.
- The user appears under Users in the
dynamo-airealm. - The user is in the
all-usersgroup (from the hardcoded group mapper). - The user is missing one or more org-level roles that their Entra group membership should grant.
- Other users in the same tenant who belong to fewer groups receive the expected roles.
The issue is most common in large organizations where users inherit many security groups (department, location, distribution lists, nested memberships, and so on) beyond the groups you use for DynamoAI authorization.
Diagnosis
Step 1: Decode the ID token
Capture the ID token Entra ID returns during sign-in. You can use browser developer tools on the redirect back to Keycloak, or a tool such as jwt.ms.
Check the payload for:
| What you see | Meaning |
|---|---|
"groups": ["<guid>", ...] with your mapped group Object ID present | Group claim is working; look elsewhere (regex typo, wrong Object ID, sync mode). |
No groups claim, but _claim_names / _claim_sources or hasgroups: true | Group overage — this guide's fix applies. |
No groups claim and no overage indicators | Groups claim not configured on the app registration — see Adding Mappers — Step 1. |
Step 2: Confirm group count in Entra ID
In the Azure Portal, open the affected user under Microsoft Entra ID → Users and review Groups. If the user is a member of a large number of security groups (approaching or exceeding 200, or simply many more than the handful you use for DynamoAI), overage is the likely cause.
Step 3: Verify Keycloak mappers
In the dynamo-ai realm, open the Entra identity provider and confirm:
- Advanced Claim to Role mappers use claim key
groups. - The regex values contain the correct Entra security group Object IDs (not display names).
- No duplicate Hardcoded Role mapper grants the same role unconditionally.
If the token lacks groups entirely, mapper configuration alone cannot fix the problem.
Solution
Limit which groups Entra ID emits in the token by configuring the groups claim to include only groups assigned to the dynamoai-idp enterprise application, then assign the security groups you use for DynamoAI role mapping. This keeps the groups claim within token limits and lets Keycloak mappers continue to work without Graph API integration.
1. Change the groups claim source
In Customer-Entra-ID (Azure Portal):
-
Open the
dynamoai-idpapp registration. -
Go to Token configuration.
-
If a groups claim already exists, remove it and re-add it (or edit via the application manifest — see below).
-
Click Add groups claim.
-
Under group types, select Groups assigned to the application (not Security groups or All groups).
Microsoft recommends this option for large organizations because it avoids the 200-group JWT limit. See Configure groups optional claims — Groups assigned to the application.
-
Under customize token properties for the ID token, choose Group ID (required for Object ID–based Keycloak mappers).
-
Save.
2. Assign the authorization groups to the enterprise application
The groups claim only includes groups assigned to the application, so each Entra security group that should drive DynamoAI role assignment must be explicitly assigned:
-
Go to Microsoft Entra ID → Enterprise applications.
-
Search for and open
dynamoai-idp. -
Go to Users and groups.
-
Click Add user/group.
-
For each security group referenced in your Keycloak Advanced Claim to Role mappers, add that group (not individual users).
Example: if mappers reference groups
DynamoAI-DevelopersandDynamoAI-Admins, assign both groups here. -
Save.
You do not need to assign every group the user belongs to in the directory — only the groups whose Object IDs appear in your Keycloak mapper regexes.
3. Retest
- Have an affected user sign out and sign in again through Entra ID.
- Decode the new ID token and confirm the
groupsclaim is present and contains the expected Object IDs. - In Keycloak (
dynamo-airealm → Users), confirm the user received the mapped org-level roles.
What not to do
| Approach | Why it does not work for DynamoAI |
|---|---|
| Query Microsoft Graph from Keycloak at login | Keycloak IdP mappers do not support Graph lookups via _claim_sources. |
Assume the user has no groups when groups is absent | Overage omits the claim; membership may still include your mapped groups. |
| Add every directory group to the enterprise application | Defeats the purpose of limiting emitted groups and may reintroduce overage. |
Verification checklist
After applying the fix:
- ID token from a previously affected user contains a
groupsclaim (decode at jwt.ms). - The
groupsclaim includes the Object ID(s) referenced in Keycloak Advanced Claim to Role mappers. - No
_claim_names,_claim_sources, orhasgroupsoverage indicators appear in the token. - Keycloak shows the expected org-level roles on the user after re-login.
- A user not in any mapped group still receives
all-usersbut not claim-mapped roles.
Related Guides
- Adding Mappers — Mapping Entra ID Security Groups to DynamoAI Roles — Initial groups claim and mapper setup
- Entra ID as IdP — Registering the IdP and configuring the
dynamoai-idpapplication - Troubleshooting IdP Logins — Other post-login issues (missing Policies tab, email claim, and so on)