Claude Opus 5.5 · Heavy

implement-access-token-context-encoding-framework-keycloak

Keycloak · Java · L · 300–799 lines · 6 files

The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Haiku 5.5.

Gold bugs found
0 of 0
Comments published
9
Comments matching a bug
0
Comments not matching
9
Cost of this PR
$4.523

Published comments (9)

mediumbugserver-spi-private/src/main/java/org/keycloak/protocol/oidc/grants/OAuth2GrantTypeFactory.java:29-33

Javadoc says 3-letter shortcut but token id decoding needs exactly 2 — A custom grant that follows this doc with a 3-letter shortcut produces access token ids that `DefaultTokenContextEncoderProvider` cannot decode, because it expects a 6-character prefix with 2 characters per part. State that the shortcut must be exactly 2 characters.

mediumbugservices/src/test/java/org/keycloak/protocol/oidc/encode/DefaultTokenContextEncoderProviderTest.java:76-85

testIncorrectGrantType passes via a NullPointerException, not the grant-type check — Deleting the `IllegalArgumentException` check would not fail this test: the null `sessionFactory` (no `postInit`) makes `getGrantTypeByShortcut` throw a `NullPointerException`, which the `RuntimeException` catch swallows. Catch only `IllegalArgumentException` and set up the fixture so the provider-factory lookup returns nothing.

mediumbugservices/src/main/java/org/keycloak/protocol/oidc/encode/AccessTokenContext.java:73

rawTokenId null check tests grantType instead of rawTokenId — A null `rawTokenId` slips through despite the error message, so the encoded token id ends in the string "null". Pass `rawTokenId` to `Objects.requireNonNull` instead of `grantType`.

mediumbugtestsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AssertEvents.java:482-483

Grant shortcut is read from the wrong substring, so the grant is never checked — The prefix is session type, then token type, then grant, 2 characters each, so `substring(3, 5)` straddles the token type and grant and never compares the real shortcut. Use `items[0].substring(4, 6)`.

mediumbugtestsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AssertEvents.java:482-483

Access token ID matcher reads the wrong substring for the grant shortcut — The grant sits after 2 characters of session type and 2 of token type, so `substring(3, 5)` mixes the token-type and grant fields and the real shortcut is never checked. Use `substring(4, 6)`.

mediumbugtestsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AssertEvents.java:482-483

Grant shortcut read from the wrong offset in access token ID — The encoder places the grant at characters 5-6 (session 2 + token 2 + grant 2), so `substring(3, 5)` compares the wrong two characters and the comment is also wrong. Use `substring(4, 6)` and say the shortcut starts at the 5th character.

mediumbugtestsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AssertEvents.java:482-483

Grant shortcut is read from the wrong substring indices of the token ID — `substring(3, 5)` is one position too early: for "onrtac" it returns "ta" instead of "ac", since the grant is the last 2 characters of the 6-character prefix. Use `items[0].substring(4, 6)` and fix the comment about the starting character.

mediumbugtestsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AssertEvents.java:482-483

Grant shortcut in access token ID is read from the wrong offset — `encodeTokenId` writes the grant after 2 characters of session type and 2 of token type, so `substring(3, 5)` mixes token-type and grant characters ("ta" for "onrtac") and the grant is never compared. Use `items[0].substring(4, 6)`.

mediumbugtestsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AssertEvents.java:483

Inverted grant-shortcut check in isAccessTokenId rejects matching tokens — Tokens with the expected grant are rejected while tokens with any other grant are accepted, because the matcher returns false on equality. Return false only when the shortcut does not equal `expectedGrantShortcut`.

Gold bugs found (0)

None.

Gold bugs missed (0)

None.