fix(core): infer JWT algorithms for JWKS keys without alg#3434
fix(core): infer JWT algorithms for JWKS keys without alg#3434strantalis merged 4 commits intomainfrom
Conversation
Signed-off-by: strantalis <strantalis@virtru.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request updates the authentication token verification logic to handle JWKS keys that do not specify an algorithm. By enabling automatic algorithm inference, the system becomes more robust when interacting with Identity Providers that omit the 'alg' field in their key sets, ensuring consistent JWT validation without compromising existing security configurations. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. When keys arrive without a sign, / To tell us how to draw the line, / We infer the way to make it true, / And let the auth pass safely through. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request updates the token verification logic to support JWKS keys that do not explicitly include an 'alg' field by enabling algorithm inference via jws.WithInferAlgorithmFromKey(true). Additionally, the test suite was updated with a new test case to verify that tokens can be successfully validated even when the JWKS key is missing the algorithm specification. I have no feedback to provide as there were no review comments to evaluate.
|
Caution Review failedFailed to post review comments 📝 WalkthroughWalkthroughJWT verification now instructs the parser to infer the signing algorithm from the JWKS verification key ( ChangesJWT Algorithm Inference for Token Verification
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
Signed-off-by: strantalis <strantalis@virtru.com>
X-Test Failure Report✅ js-pull-3434 |
Signed-off-by: strantalis <strantalis@virtru.com>
X-Test Failure Report |
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
Signed-off-by: strantalis <strantalis@virtru.com>
|
@CodeRabbit please review this pr again |
|
Tip For best results, initiate chat on the files or code changes.
[full_review] |
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
|
Summary
alg, such as Microsoft Entra.jws.WithInferAlgorithmFromKey(true)tojwt.WithKeySetwhile preserving issuer, audience, skew, kid, and signature validation.kidbut noalg.Jira
Testing
~/go/bin/gofumpt -w service/internal/auth/token_verifier.go service/internal/auth/token_verifier_test.gocd service && go test ./internal/auth -run 'TestTokenVerifier|TestNewTokenVerifier' -vcd service && go test ./internal/authcd service && golangci-lint run --new ./internal/authKnown Existing Failures
cd service && golangci-lint run ./internal/authfails on pre-existing unused//nolintdirectives inauthn.go.make testfails inlib/fixturesonTestTokenManager_InitialLoginandTestTokenManager_CustomTokenBuffer, unrelated to this auth verifier change.Summary by CodeRabbit
Bug Fixes
Tests