Repository navigation
Conversation
The SAML metadata-backed client key lookup builds the public-key storage cache key from the realm ID and the client UUID via getClientModelCacheKey(realmId, client.getId()). However, the lookup in SamlProtocolUtils.createKeyLocatorForClient passed client.getClientId() (the human-readable client ID string) instead of client.getId() (the internal UUID). Client update/removal events invalidate cache entries built from the internal client UUID, so the two keys never matched and a stale SAML metadata signing key survived client updates indefinitely (e.g. after a metadata URL or key-material rotation), being trusted until cache eviction or manual reload. Fix: use client.getId() so the lookup uses the same UUID-based cache key that InfinispanPublicKeyStorageProviderFactory invalidates on ClientUpdatedEvent/ClientRemovedEvent. Signed-off-by: waterWang <waterWang@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Aligns SAML metadata public-key cache lookup with client update/removal invalidation.
Changes:
- Uses the internal client UUID instead of the human-readable client ID for cache keys.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (StringUtil.isNotBlank(samlClient.getMetadataDescriptorUrl()) && samlClient.isUseMetadataDescriptorUrl()) { | ||
| // configured to use the metadata | ||
| String modelKey = PublicKeyStorageUtils.getClientModelCacheKey(samlClient.getClient().getRealm().getId(), samlClient.getClient().getClientId()); | ||
| String modelKey = PublicKeyStorageUtils.getClientModelCacheKey(samlClient.getClient().getRealm().getId(), samlClient.getClient().getId()); |
Contributor
|
Hi @waterWang, thank you for creating the PR. Please can you also add a test, this is a must requirement to accept the bug fix. Thank you for understanding. |
Contributor
|
closing the issue, since the reporter is not responding, it will be fixed in a separate PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #52106
Problem
SamlProtocolUtils.createKeyLocatorForClient()builds the public-key storage cache key withclient.getClientId()(the human-readable SAML client ID string), whileInfinispanPublicKeyStorageProviderFactoryinvalidates cache entries built fromclient.getId()(the internal client UUID) onClientUpdatedEvent/ClientRemovedEvent.Because these two keys never match, a client update (e.g. rotating the SAML metadata URL or key material) does not evict the stale SAML metadata public-key entry. The retired signing certificate remains cached and trusted indefinitely (no
validUntil/cacheDurationmeans no expiration), until cache eviction or manual reload.Fix
Use
client.getId()in the lookup so it uses the same UUID-based cache key that invalidation targets.Verification
realm::client::<clientId-string>::keyuse::SIG(≠ invalidation)realm::client::<client-uuid>::keyuse::SIG(== invalidation for SIG; ENC variant also covered)No DCO / Apache-2.0 licensed repo contribution.