Skip to content

[OID4VCI] Namespace credential offer cache entries with realm-scoped keys - #51307

Merged
mposolda merged 1 commit into
keycloak:mainfrom
adorsys:issue-51198
Jul 30, 2026
Merged

[OID4VCI] Namespace credential offer cache entries with realm-scoped keys#51307
mposolda merged 1 commit into
keycloak:mainfrom
adorsys:issue-51198

Conversation

@Awambeng

Copy link
Copy Markdown
Contributor

This PR prevents cross-realm cache collisions in DefaultCredentialOfferStorage by namespacing single-use cache entries with a prefix and realm ID, following the same pattern used by ParEndpoint.

Key changes:

  • Cache keys are changed from <offerId> to oid4vc_offer:<realmId>:<offerId> to prevent a credential offer created in one realm from being consumed in another realm when both have matching offer IDs.
  • Added a CACHE_KEY_PREFIX constant and a buildCacheKey helper to derive the realm from the session context and centralize the realm binding logic.
  • getOfferStateByNonce inherits the fix transparently since it resolves the offer ID and delegates to getOfferStateById.

Closes #51198

Closes keycloak#51198

Signed-off-by: Awambeng Rodrick <awambengrodrick@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Namespaces OID4VCI credential-offer cache entries by realm to prevent cross-realm collisions.

Changes:

  • Adds realm-scoped oid4vc_offer: cache keys for storage, retrieval, and removal.
  • Adds unit coverage for prefixed keys and storage behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
DefaultCredentialOfferStorage.java Builds and consistently applies realm-scoped cache keys.
DefaultCredentialOfferStorageTest.java Tests prefixed storage, retrieval, removal, and expiration.

@mposolda mposolda left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Awambeng Thanks!

@mposolda mposolda self-assigned this Jul 30, 2026
@mposolda
mposolda merged commit c0395ab into keycloak:main Jul 30, 2026
91 checks passed
@Awambeng
Awambeng deleted the issue-51198 branch July 30, 2026 13:43
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.

[OID4VCI] Make sure that cache entries in DefaultCredentialOfferStorage use prefix

3 participants