[OID4VCI]: Fix getAttestationRequirements() for non-JWT proof types - #50724
[OID4VCI]: Fix getAttestationRequirements() for non-JWT proof types#50724Awambeng wants to merge 2 commits into
getAttestationRequirements() for non-JWT proof types#50724Conversation
There was a problem hiding this comment.
Pull request overview
Fixes OID4VCI attestation validation so key_attestations_required is read from the actual proof-type entry being validated (e.g., attestation) rather than always reading the jwt entry, aligning behavior with configured metadata and closing #50521.
Changes:
- Thread the proof-type key through
validateAttestationPayload(...)intogetAttestationRequirements(...). - Replace the hardcoded
ProofType.JWTlookup with.get(proofTypeKey), and remove the unused static import. - Add unit tests verifying correct lookup for both
jwtandattestation, plus missing/unsupported configuration cases.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| services/src/main/java/org/keycloak/protocol/oid4vc/issuance/keybinding/AttestationValidatorUtil.java | Fixes attestation requirements lookup to use the provided proof-type key instead of hardcoding jwt. |
| services/src/test/java/org/keycloak/protocol/oid4vc/issuance/keybinding/AttestationValidatorUtilTest.java | Adds coverage proving requirements are read from the correct proof-type entry and handles missing config gracefully. |
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.forms.BrowserFlowTest#testUserWithOneAdditionalFactorOtpSuccessorg.keycloak.testsuite.forms.MultipleTabsLoginTest#multipleTabsParallelLoginTestWithAuthSessionExpiredAndRefreshInTab1Keycloak CI - Forms IT (chrome) org.keycloak.testsuite.webauthn.AppInitiatedActionWebAuthnSkipIfExistsTest#processSetupTwice |
- Thread proofTypeKey through validateAttestationPayload() to getAttestationRequirements() - Replace the hardcoded .get(JWT) lookup with .get(proofTypeKey) - Remove the unused ProofType.JWT import - Add unit tests verifying attestation requirements are read for the correct proof type Closes keycloak#50521 Signed-off-by: Awambeng Rodrick <awambengrodrick@gmail.com>
Signed-off-by: Awambeng Rodrick <awambengrodrick@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
services/src/main/java/org/keycloak/protocol/oid4vc/issuance/keybinding/AttestationValidatorUtil.java:87
- The parameter name
proofTypeKeyForSigningAlgPolicyno longer matches its expanded responsibility (it now affects both signing-alg policy andkey_attestations_requiredlookup). Consider renaming the parameter (and corresponding Javadoc tag) to something likeproofTypeKey/proofTypeKeyForConfigLookupto reflect its actual usage.
* @param proofTypeKeyForSigningAlgPolicy {@link org.keycloak.protocol.oid4vc.model.ProofType} value
* ({@code jwt} or {@code attestation}) to resolve
* {@code proof_signing_alg_values_supported} and
* {@code key_attestations_required}; if {@code null}, falls back to
* {@code ProofType.JWT} for attestation requirements and FAPI
* {@code ALLOWED_ALGORITHMS} for signing algorithms.
services/src/test/java/org/keycloak/protocol/oid4vc/issuance/keybinding/AttestationValidatorUtilTest.java:99
- This comment states an invariant ('always ... never null') that conflicts with the production code’s defensive null checks. To avoid misleading future maintainers, reword to only describe the intent of the test (e.g., that it covers the empty-map case) without asserting the map can never be null.
// supportedProofTypes is always an initialized HashMap (never null), so this covers the empty-map case.
This PR fixes
getAttestationRequirements()to use the configured proof type instead of always reading thejwtconfiguration.Key changes
proofTypeKeythroughvalidateAttestationPayload()togetAttestationRequirements()ProofType.JWTlookup withproofTypeKeyProofType.JWTimportjwtandattestationproof types and missing configuration casesCloses #50521