Skip to content

Fix SAML v2 API: null/omitted string attributes now remove model attributes - #51252

Draft
shawkins with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-saml-string-attribute-mapper
Draft

Fix SAML v2 API: null/omitted string attributes now remove model attributes#51252
shawkins with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-saml-string-attribute-mapper

Conversation

Copilot AI commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

In the Admin API v2 SAML mapper, setAttributeIfNotNull and setBooleanAttributeIfNotNull silently ignored null values, so PATCH with an explicit null or a PUT omitting a field (e.g. signingCertificate) left the underlying model attribute intact. A stale signing certificate would remain trusted for SAML signature verification despite the API returning 200.

Changes

  • SAMLClientModelMapper: Both setAttributeIfNotNull and setBooleanAttributeIfNotNull now call model.removeAttribute(key) when the value is null, aligning with the expected merge-patch and PUT replace semantics.

  • SAMLClientModelMapperTest: Updated toModel_doesNotSetNullAttributestoModel_removesAttributesWhenNull to assert the corrected behavior; also adds signingCertificate to the verified attributes.

Behavior

Operation Field state Before After
PATCH "signingCertificate": null attribute retained attribute removed
PUT field omitted attribute retained attribute removed
PATCH field omitted attribute retained (via readerForUpdating) unchanged ✓

Note: Jackson's readerForUpdating preserves absent fields from the base representation during merge-patch, so omitted PATCH fields are never null when toModel is called — only explicitly nulled fields are.

When a SAML client attribute is set to null (via PATCH with explicit null
or PUT omitting the field), the v2 mapper now removes the corresponding
model attribute instead of silently ignoring the null value.

Previously, `setAttributeIfNotNull` and `setBooleanAttributeIfNotNull`
would skip null values, leaving stale attributes (e.g. signingCertificate)
in place. This was a security concern since an administrator who PATCHed
`signingCertificate: null` would receive a 200 but the old certificate
would still be trusted for SAML signature verification.

Closes #51213
Copilot AI changed the title [WIP] Fix SAML string-attribute mapper to remove attributes on null Fix SAML v2 API: null/omitted string attributes now remove model attributes Jul 28, 2026
Copilot AI requested a review from shawkins July 28, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admin API v2: SAML string-attribute mapper does not remove attributes on explicit null or omission

2 participants