Skip to content

[OID4VCI] Ensure credential configuration IDs are unique - #51272

Merged
mposolda merged 3 commits into
keycloak:mainfrom
adorsys:issue-51185
Jul 30, 2026
Merged

[OID4VCI] Ensure credential configuration IDs are unique#51272
mposolda merged 3 commits into
keycloak:mainfrom
adorsys:issue-51185

Conversation

@forkimenjeckayang

@forkimenjeckayang forkimenjeckayang commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Enforces explicit and unique OID4VCI credential configuration IDs when client scopes are created, updated, or imported.

Changes

  • Remove the client-scope name fallback from CredentialScopeModel.getCredentialConfigurationId().
  • Default missing or blank credential configuration IDs to the client-scope name during creation, update, and realm import.
  • Reject creation, update, or realm import when the effective credential configuration ID is already used by another OID4VCI client scope.
  • Return HTTP 409 for duplicate credential configuration IDs.
  • Serialize concurrent uniqueness checks using realm-scoped transactional locking.
  • Ensure update validation cannot be bypassed by omitting the representation ID or protocol.
  • Apply defaults using the target protocol when changing a client scope’s protocol.
  • Apply protocol-specific validation and defaults when importing client scopes.
  • Remove the additional scope-name fallback when generating issuer metadata.
  • Add coverage for:
    • explicit and implicit duplicate IDs;
    • duplicate updates;
    • concurrent duplicate creation;
    • blank-ID defaulting;
    • updates with an omitted protocol or representation ID;
    • switching client scopes to OID4VCI;
    • realm-import defaulting and duplicate rejection;
    • removal of the model fallback.

Closes #51185

Signed-off-by: forkimenjeckayang <forkimenjeckayang@gmail.com>
Copilot AI review requested due to automatic review settings July 29, 2026 14:31
@forkimenjeckayang
forkimenjeckayang requested a review from a team as a code owner July 29, 2026 14:31

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

Ensures OID4VCI credential configuration IDs are explicit and unique.

Changes:

  • Removes scope-name fallbacks.
  • Defaults blank IDs and validates uniqueness.
  • Adds integration coverage for duplicate and omitted-field updates.

Reviewed changes

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

Show a summary per file
File Description
tests/base/src/test/java/org/keycloak/tests/oid4vc/OID4VCClientScopeTest.java Tests defaulting and uniqueness behavior.
services/src/main/java/org/keycloak/services/resources/admin/ClientScopeResource.java Normalizes update identifiers and protocols.
services/src/main/java/org/keycloak/protocol/oid4vc/OID4VCLoginProtocolFactory.java Defaults and validates configuration IDs.
services/src/main/java/org/keycloak/protocol/oid4vc/model/SupportedCredentialConfiguration.java Rejects missing IDs during metadata generation.
server-spi-private/src/main/java/org/keycloak/models/oid4vci/CredentialScopeModel.java Removes the model fallback.

Signed-off-by: forkimenjeckayang <forkimenjeckayang@gmail.com>
Copilot AI review requested due to automatic review settings July 30, 2026 07:46
@forkimenjeckayang
forkimenjeckayang requested review from a team as code owners July 30, 2026 07:46

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

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

Comments suppressed due to low confidence (1)

services/src/main/java/org/keycloak/protocol/oid4vc/OID4VCLoginProtocolFactory.java:234

  • Realm import still bypasses this hook: DefaultExportImportManager.createClientScopes calls RepresentationToModel.createClientScope directly, so an imported realm can persist duplicate or missing OID4VCI configuration IDs. That leaves the uniqueness issue reproducible through a supported creation path (and a missing ID now makes issuer metadata throw); apply the same defaulting and validation during import or centralize it below both paths.
        validateCredentialConfigurationId(session, clientScope);

Signed-off-by: forkimenjeckayang <forkimenjeckayang@gmail.com>
Copilot AI review requested due to automatic review settings July 30, 2026 08:05

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

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

Comments suppressed due to low confidence (1)

services/src/main/java/org/keycloak/protocol/oid4vc/model/SupportedCredentialConfiguration.java:108

  • Existing realms can contain OID4VC scopes without this attribute because the previous realm-import path persisted them without applying protocol defaults. After an upgrade, this exception makes issuer metadata generation fail for those otherwise valid scopes; backfill/normalize existing scopes during migration (including collision handling) before removing the runtime fallback.
                .orElseThrow(() -> new IllegalStateException("No credential configuration ID in client scope: "
                        + credentialScope.getName()));

@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.

@mposolda
mposolda merged commit 1550152 into keycloak:main Jul 30, 2026
92 checks passed
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] Uniqueness of credential configuration ID

3 participants