mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-21 20:38:47 +00:00
fix: Revert "feat(oidc): Added new claim in userinfo response to return all requested audience roles (#9861)" (#10874)
# Which Problems Are Solved #9861 added a `urn:zitadel:iam:org:projects:roles` claims to include all roles from all requested roles. The intention was to return them on the userinfo endpoint. But since the claims might also be returned in the id and access tokens, they can grow big quite fast and break the size limits for headers. # How the Problems Are Solved This PR revert the feature. The information for roles of other projects is already available as a dedicated claim (for each project): ```json "urn:zitadel:iam:org:project:328813096124547391:roles": { "r2": { "306639557921669515": "zitadel.localhost" }, "r3": { "306639557921669515": "zitadel.localhost" }, "role": { "306639557921669515": "zitadel.localhost" } }, "urn:zitadel:iam:org:project:341406882914631999:roles": { "role": { "306639557921669515": "zitadel.localhost", "328237605990695334": "aa.localhost" }, "test": { "306639557921669515": "zitadel.localhost", "328237605990695334": "aa.localhost" } }, "urn:zitadel:iam:org:project:roles": { "r2": { "306639557921669515": "zitadel.localhost" }, "r3": { "306639557921669515": "zitadel.localhost" }, "role": { "306639557921669515": "zitadel.localhost" } } ``` # Additional Changes None # Additional Context - relates to #9861 - noted issues in production - requires backport to v4.x
This commit is contained in:
@@ -209,7 +209,7 @@ func assertRoles(projectID string, user *query.OIDCUserInfo, roleAudience, reque
|
||||
}
|
||||
// prevent returning obtained grants if none where requested
|
||||
if (projectID != "" && len(requestedRoles) > 0) || len(roleAudience) > 0 {
|
||||
setUserInfoRoleClaims(info, newProjectRoles(projectID, user.UserGrants, requestedRoles, roleAudience))
|
||||
setUserInfoRoleClaims(info, newProjectRoles(projectID, user.UserGrants, requestedRoles))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,25 +278,12 @@ func setUserInfoOrgClaims(user *query.OIDCUserInfo, out *oidc.UserInfo) {
|
||||
|
||||
func setUserInfoRoleClaims(userInfo *oidc.UserInfo, roles *projectsRoles) {
|
||||
if roles != nil && len(roles.projects) > 0 {
|
||||
// Create a map to store accumulated roles for ClaimProjectsRoles
|
||||
projectsRoles := make(projectRoles)
|
||||
|
||||
for requestAudID := range roles.requestAudIDs {
|
||||
if projectRole, ok := roles.projects[requestAudID]; ok {
|
||||
maps.Copy(projectsRoles, projectRole)
|
||||
}
|
||||
}
|
||||
|
||||
if roles, ok := roles.projects[roles.requestProjectID]; ok {
|
||||
userInfo.AppendClaims(ClaimProjectRoles, roles)
|
||||
}
|
||||
for projectID, roles := range roles.projects {
|
||||
userInfo.AppendClaims(fmt.Sprintf(ClaimProjectRolesFormat, projectID), roles)
|
||||
}
|
||||
// Finally, set the accumulated ClaimProjectsRoles
|
||||
if len(projectsRoles) > 0 {
|
||||
userInfo.AppendClaims(ClaimProjectsRoles, projectsRoles)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user