Fix external OAuth role mapping regression in v78#3814
Fix external OAuth role mapping regression in v78#3814ybykov-a9s wants to merge 1 commit intocloudfoundry:developfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Restores pre-v78 behavior for external OAuth/OIDC users by ensuring externalGroups on UaaAuthentication is derived from mapped internal UAA authorities (not raw upstream IdP groups), preserving backward-compatible token role semantics.
Changes:
- Populate
UaaAuthentication.externalGroupsfromauthenticationData.authorities(mapped/internal) instead ofauthenticationData.externalAuthorities(raw/upstream). - Update/add a focused regression test asserting
externalGroupscomes from mapped authorities and excludes raw external groups.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
server/src/main/java/org/cloudfoundry/identity/uaa/provider/oauth/ExternalOAuthAuthenticationManager.java |
Fixes populateAuthenticationAttributes to source externalGroups from mapped authorities to restore v77 token role semantics. |
server/src/test/java/org/cloudfoundry/identity/uaa/provider/oauth/ExternalOAuthAuthenticationManagerTest.java |
Renames and adjusts the regression test to validate the corrected externalGroups source. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@duanemay My main concern is, that we dont have any Integration Test which would found the change before and also this PR has no effects on ITs |
|
About my testings. I setup a similar env to check what was our behaviour in 77.35 and now. Problem is and was that we had a different behaviour for SAML and OIDC. In SAML the roels in id_token was always the external groups in OIDC it was the mapped version. Problem is: the behaviour in OIDC is not only in 77.35 like this but a long time and maybe adopted from LDAP behaviour, @fhanik any thoughts ? From my side we can accept this PR and then need an Integration tests to fix this behaviour to OIDC |
|
As I'm reviewing this, here is what I have found The change proposed does change the intended behavior relative to SAML and LDAP. Before (using getExternalAuthorities()): After (using getAuthorities()): The modification collapses the usual split: elsewhere externalGroups = external, authorities = internal/mapped; with getAuthorities() While this code may have been alive for quite some time (years), it is still a bug, as group mapping should be consistent across all IDP. I'm inclined to introduce a configuration option that would allow an installation to have to old behavior (bug in place) with the default being that UAA is aligned with the same group mapping behavior regardless of IDP type or grant type. @ybykov-a9s @strehle Thoughts? |
|
I have provided a proposed solution in #3821 |
|
Closed. Merged in #3821 |
Summary
This PR fixes a backward-compatibility regression introduced in v78 where token role content for external OAuth or OIDC users changed from mapped internal UAA authorities to raw upstream IdP groups.
Before this change:
After this change:
Problem
After upgrading from v77.35.0 to v78.6.0, role-related token content changed:
This is a behavior regression, not a field ordering issue.
Root Cause
In
ExternalOAuthAuthenticationManager.populateAuthenticationAttributes, externalGroups was built from authenticationData.externalAuthorities, which contains raw groups from the IdP.That value is later persisted and reused in token construction paths, causing raw groups to appear where mapped internal authorities were expected.
Fix
Use authenticationData.authorities, which contains mapped internal authorities, when populating externalGroups.
In short:
Why this is correct
Tests
Added or updated focused regression coverage in ExternalOAuthAuthenticationManagerTest to verify:
Targeted test execution:
Compatibility Impact
This change restores prior behavior and reduces upgrade risk for installations relying on mapped internal authorities in token role content.
Issue
Fixes issue