[OID4VCI] Ensure credential configuration IDs are unique - #51272
Merged
Conversation
Signed-off-by: forkimenjeckayang <forkimenjeckayang@gmail.com>
Contributor
There was a problem hiding this comment.
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>
Contributor
There was a problem hiding this comment.
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.createClientScopescallsRepresentationToModel.createClientScopedirectly, 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>
Contributor
There was a problem hiding this comment.
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
approved these changes
Jul 30, 2026
mposolda
left a comment
Contributor
There was a problem hiding this comment.
@forkimenjeckayang Thanks!
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.
Summary
Enforces explicit and unique OID4VCI credential configuration IDs when client scopes are created, updated, or imported.
Changes
CredentialScopeModel.getCredentialConfigurationId().Closes #51185