refactor(access-control-service): reuse SecurityContext to skip duplicate JWT parse#5560
Open
Yicong-Huang wants to merge 2 commits into
Open
refactor(access-control-service): reuse SecurityContext to skip duplicate JWT parse#5560Yicong-Huang wants to merge 2 commits into
Yicong-Huang wants to merge 2 commits into
Conversation
…cate JWT parse Closes apache#5559
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5560 +/- ##
=========================================
Coverage 52.16% 52.17%
Complexity 2482 2482
=========================================
Files 1067 1067
Lines 41273 41276 +3
Branches 4437 4439 +2
=========================================
+ Hits 21532 21534 +2
Misses 18479 18479
- Partials 1262 1263 +1
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ion and clarify control flow Replace fold with an explicit match so the fallback parse is visually unambiguous, and stop re-extracting the Bearer token from the Authorization header — JwtAuthFilter already does that work and exposes the SessionUser via the SecurityContext.
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.
What changes were proposed in this PR?
In
AccessControlResource, whenSecurityContext.getUserPrincipalis already aSessionUserpopulated byJwtAuthFilter(the Authorization-header path), reuse it instead of callingJwtParser.parseTokenon the same token again. Falls back to parsing the query/body token only when no principal is available, preserving WebSocket (?access-token=) and form-POST (bodytoken) flows that the filter does not see.Why are the changes needed?
Related issues: Closes #5559
How was this PR tested?
Added unit test covering the SecurityContext-reuse path; existing
AccessControlResourceSpeccases continue to exercise the query/body fallback.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 4.7