Conversation
Decode the verified JWT payload directly when extracting map claims. Add regression tests and a standalone RSA-2048 verification benchmark. Assisted-By: LLM, GPT 6 Astra
9 tasks
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 12 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
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.
Description
VerifyAccessTokencurrently parses the JWT again withParseUnverifiedafter signature and claim validation, just to collect the arbitrary claims. This change decodes the payload directly at that point, avoiding another parse of the header and signature.Signature and registered-claim validation still happen first. The added tests cover nested claims, numeric claim types, malformed JSON numbers, a null payload, and rejection of invalid signatures, issuers, expired tokens and tokens used before
nbf.This is the performance change split out of #3466 as requested in review. It is based on
mainand can be reviewed and merged independently of the audience validation changes.Related Issue
Motivation and Context
The second parser call repeats work for every verified JWT access token. Decoding only its payload reduces allocations while keeping the existing map-claim behavior and error wrapping.
How Has This Been Tested?
Ubuntu WSL, Go 1.25.9, linux/amd64, vendored dependencies.
main(a065c9ee19) first. They pass there too.go test -mod=vendor -race -count=1 ./pkg/oidc/... ./services/proxy/...passed for this branch and for feat(proxy): add optional OIDC access token audience validation #3466 with the performance commit removed../pkg/oidc/...passed with no new findings.Added
BenchmarkVerifyAccessTokenClaims, which measures full RS256 access-token verification and map-claim extraction using a local RSA-2048 key and JWKS. It makes no network requests.Fresh measurements after closing unnecessary applications, using the same benchmark for both versions: six alternating 2-second samples per version, one CPU, Intel Core Ultra 7 155U. The baseline is
mainata065c9ee19plus the new test file.That is 1,088 fewer bytes and 21 fewer allocations per verification. The time median is about 6.6% lower, but individual samples varied substantially (before: 70.8–100.0 µs, after: 67.3–110.7 µs). The allocation reduction is consistent; these timings are a local microbenchmark, not an end-to-end proxy throughput result.
To run the benchmark:
Types of changes
Checklist
Assisted-By: LLM, GPT 6 Astra