Repository navigation
Conversation
JWSHeader keeps "alg" as a string, so tokens signed by a custom SignatureProvider can be parsed. getAlgorithm() returns null for algorithms not in the enum, getRawAlgorithm() returns the original value. Closes keycloak#53413 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Dmitrii Gabor <dmitryg1709@gmail.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Service verification paths still dereference the nullable enum and therefore reject custom algorithms.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Allows JWS headers to retain custom algorithm names while preserving enum access for known algorithms.
Changes:
- Stores
algas a raw string. - Handles unknown algorithms in verification and SD-JWT.
- Adds header parsing and serialization tests.
| File | Description |
|---|---|
JWSHeader.java |
Supports raw custom algorithms. |
TokenVerifier.java |
Reports unsupported algorithms cleanly. |
JwsToken.java |
Compares raw algorithm names. |
JWSHeaderTest.java |
Tests parsing and serialization. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Look up signature providers by JWSHeader.getRawAlgorithm() instead of getAlgorithm().name(), so algorithms that are not in the Algorithm enum reach their providers. A missing alg is still rejected. Closes keycloak#53413 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Dmitrii Gabor <dmitryg1709@gmail.com>
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.


Closes #53413
JWSHeaderkeepsalgas a string, so a token signed by a customSignatureProvidercan be parsed by Keycloak itself (introspection, userinfo, logout, request objects,private_key_jwt).getAlgorithm()returns theAlgorithmvalue, ornullifalgis not in the enum.getRawAlgorithm()returns the originalalgvalue.TokenVerifier.verifySignature()without a verifier context reports "Unknown or unsupported token algorithm" instead of an NPE.JwsToken(SD-JWT) compares the raw algorithm, so a custom algorithm can match its verifier.services(introspection, userinfo, logout, client JWT authentication, DPoP, OID4VC, login actions, client registration) look up providers bygetRawAlgorithm(); a missingalgis still rejected.Header serialization is unchanged. Tests:
JWSHeaderTest(incl. a customSignatureVerifierContext); allkeycloak-coreandkeycloak-servicesunit tests pass.Discussion: #53407. Overlaps with #50358 (ML-DSA); happy to rebase on it.
🤖 Generated with Claude Code