8000 Allow JWS header with algorithms not in the Algorithm enum by dmitrygx · Pull Request #53415 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Allow JWS header with algorithms not in the Algorithm enum - #53415

Open
dmitrygx wants to merge 2 commits into
keycloak:mainfrom
dmitrygx:53413-jws-custom-alg
Open

dmitrygx wants to merge 2 commits into
keycloak:mainfrom
dmitrygx:53413-jws-custom-alg

Conversation

@dmitrygx
@dmitrygx dmitrygx commented Oct 1, 2026 •
Copy link
Copy Markdown

Closes #53413

JWSHeader keeps alg as a string, so a token signed by a custom SignatureProvider can be parsed by Keycloak itself (introspection, userinfo, logout, request objects, private_key_jwt).

  • getAlgorithm() returns the Algorithm value, or null if alg is not in the enum.
  • getRawAlgorithm() returns the original alg value.
  • 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.
  • Signature verification paths in services (introspection, userinfo, logout, client JWT authentication, DPoP, OID4VC, login actions, client registration) look up providers by getRawAlgorithm(); a missing alg is still rejected.

Header serialization is unchanged. Tests: JWSHeaderTest (incl. a custom SignatureVerifierContext); all keycloak-core and keycloak-services unit tests pass.

Discussion: #53407. Overlaps with #50358 (ML-DSA); happy to rebase on it.

🤖 Generated with Claude Code

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>
Copilot AI balanced review requested due to automatic review settings October 1, 2026 13:09
@dmitrygx
dmitrygx requested a review from a team as a code owner October 1, 2026 13:09
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.

Copilot review overview

🟡 Changes recommended

Service verification paths still dereference the nullable enum and therefore reject custom algorithms.

Review effort: Balanced
Findings: 1 High severity · 1 Low severity

Open (2)
What changed in this PR

Allows JWS headers to retain custom algorithm names while preserving enum access for known algorithms.

Changes:

  • Stores alg as 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>
< 8000 div class="flex-auto d-flex flex-column flex-md-row">
Copilot AI balanced review requested due to automatic review settings October 1, 2026 13: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.

Copilot review overview

🔵 Needs a closer look

It changes cryptographic verification behavior across numerous security-sensitive authentication and token endpoints.

Review effort: Balanced
Findings: None

Resolved since last review (2)

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.

Allow JWS header with algorithms not in the Algorithm enum

2 participants

0