Repository navigation
Fix AccessTokenContext raw token id null check - #53990
Merged
mposolda merged 1 commit intoOct 19, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix enforces the intended constructor contract and includes regression coverage, with no blocking issues identified.
0 open findings
What changed in this PR
Fixes constructor validation in AccessTokenContext so null raw token IDs are rejected before encoding.
Changes:
- Corrects the duplicated
grantTypecheck to validaterawTokenId. - Adds null-validation tests for all four constructor arguments.
| File | Description |
|---|---|
| services/src/test/java/org/keycloak/protocol/oidc/encode/AccessTokenContextTest.java | Adds four constructor null-validation tests. |
| services/src/main/java/org/keycloak/protocol/oidc/encode/AccessTokenContext.java | Checks rawTokenId instead of checking grantType twice. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
1 of 2 tasks
DDINGJOO
force-pushed
the
fix-access-token-context-raw-token-id-check
branch
from
October 16, 2026 03:39
eb45242 to
10175f0
Compare
1 of 2 tasks
DDINGJOO
force-pushed
the
fix-access-token-context-raw-token-id-check
branch
from
October 16, 2026 03:45
10175f0 to
ba7a611
Compare
DDINGJOO
force-pushed
the
fix-access-token-context-raw-token-id-check
branch
from
October 18, 2026 08:56
77e5356 to
0624663
Compare
mposolda
previously approved these changes
Oct 19, 2026
AccessTokenContext checks grantType twice, so a null rawTokenId argument bypasses the intended validation. Replace the second check with rawTokenId and add tests covering all four constructor arguments. Closes keycloak#54051 Signed-off-by: DDINGJOO <173995233+DDINGJOO@users.noreply.github.com>
DDINGJOO
force-pushed
the
fix-access-token-context-raw-token-id-check
branch
from
October 19, 2026 14:01
0624663 to
e3d4fe4
Compare
Contributor
Author
|
@mposolda Thanks for the approval! The CI build failed on Spotless (import order in the new test), so I amended the commit with |
mposolda
approved these changes
Oct 19, 2026
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.
AccessTokenContextchecksgrantTypetwice, so a nullrawTokenIdargument bypasses the intended validation:The constructor is a
@JsonCreator, so the value also arrives from deserialized token context JSON. A null is stored and later concatenated into the encoded token id inDefaultTokenContextEncoderProvider, where it shows up as the literalnullinstead of failing fast at construction.Replace the second check with
rawTokenIdand add tests covering all four constructor arguments.Validation:
Closes #54051