Repository navigation
[2.0] fix(saml): accept repeated attribute names, so Keycloak users with roles can sign in (backport #38080) - #38447
Conversation
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
| SamlSettingsHolder.buildSettings(samlConfig("https://idp.example.com/sso")), | ||
| "https://sp.example.com/api/v1/saml/acs", |
There was a problem hiding this comment.
The new test repeats the SSO and ACS URLs already used in this file. The repository guide requires a named constant when a string appears more than once. Extract shared constants before merging so these addresses stay consistent when changed.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Done: the URLs are now the IDP_SSO_URL and SP_ACS_URL constants, used by this test and the helper. Two older tests keep the literal because PR #38441 rewrites them, and changing them here would conflict.
Code Review ✅ Approved 🔴 High riskEnabling duplicate SAML attribute merging changes sign-in claim handling; unexpected repeated role values could affect which users authenticate or receive roles. Backport of the SAML fix that enables java-saml's VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Describe your changes:
Backport of #38080 to the 2.0 branch.
On 2.0, a SAML sign-in fails when the identity provider sends the same attribute name more than once. Keycloak's default role mapper does this: it sends one
Roleattribute per role, and every Keycloak user has default roles. java-saml rejects the response with "Found an Attribute element with duplicated Name", so the user cannot sign in. I hit this on 2.0 while testing the SAML fixes for #37056 end to end against Keycloak (the login ended in a 500 at the ACS).The fix is the one from #38080:
SamlSettingsHolder.buildSettingsturns on java-saml'sallow_duplicated_attribute_name, so repeated attributes are merged into one attribute with several values.The only adaptation for 2.0 is in the test: it uses 2.0's
samlConfig(String)helper, and the import list follows 2.0's version ofSamlSettingsHolderTest.Release note (2.0.10): SAML sign-in no longer fails when the identity provider sends the same attribute more than once, as Keycloak does for users with roles. The values are merged into one attribute.
Type of change:
High-level design:
Cherry-pick of #38080. One setting plus a unit test.
Tests:
Unit tests
SamlSettingsHolderTest.buildSettingsMergesRepeatedAttributeNames: a response with twoRoleattributes is read as one attribute with both values.SamlSettingsHolderTeston this branch: 10 tests pass. With the setting removed, the new test fails, so it covers the bug.Integration, ingestion and Playwright tests: not applicable. Manual: the failure was reproduced on 2.0 against Keycloak 26.3 with a user that has roles. The fixed login was not re-run against Keycloak on 2.0; the unit test above covers it, and main has had the same setting since #38080.
UI screen recording / screenshots:
Not applicable.
Checklist:
The remaining shared-string requirement in
SamlSettingsHolderTest.javashould be satisfied before merging.Findings
Summary
Allows SAML responses to repeat an attribute name, so Keycloak role attributes can be read together.
Reviews (3) · Last reviewed commit: "Use a text block and named URLs in the r..." · Reviewed by Greptile