Amazon Ergo 1.0 · Balanced
implement-access-token-context-encoding-framework-keycloak
Keycloak · Java · L · 300–799 lines · 6 files
The normal review, with one generalist agent. Judge: Claude Opus 5.5.
- Gold bugs found
- 4 of 5
- Comments published
- 4
- Comments matching a bug
- 4
- Comments not matching
- 0
- Cost of this PR
- $4.392
Published comments (4)
isAccessTokenId extracts the grant shortcut from the wrong offsets — Valid token IDs are rejected because the matcher reads an overlapping range and treats a match as failure. Use `items[0].substring(4, 6)` for indexes 4-5, and reject the item only when the shortcut differs from `expectedGrantShortcut`.
Constructor validates grantType twice, skipping the rawTokenId null check — A null `rawTokenId` is accepted and can produce an encoded ID ending in `null` instead of failing fast. Replace the duplicate `grantType` check so `Objects.requireNonNull` validates `rawTokenId` with the existing error message.
V1 and subject-impersonation token exchange omit the 'te' grant type — Access tokens from `V1TokenExchangeProvider` and `SubjectImpersonationTokenExchangeProvider` carry `na` instead of `te`, so their encoded IDs do not identify token exchange. Set `Constants.GRANT_TYPE` in `AbstractTokenExchangeProvider` or `TokenExchangeGrantType.process` so every exchange flow inherits it.
PermissionGrantType.process leaves grant type null, encoding RPT ID as 'na' — UMA RPT IDs are encoded with `na` instead of `pg`, misidentifying permission-grant tokens. Set `Constants.GRANT_TYPE` in `PermissionGrantType.process` before calling `AuthorizationTokenService.authorize` so the authorization-token path inherits it.