refactor(proxy): Use jmespath to extract claim values#2558
Open
rhafer wants to merge 1 commit into
Open
Conversation
fee1d1c to
91641c6
Compare
01f5f0d to
74dc6f8
Compare
|
Replace the custom dot-path walking implementation (SplitWithEscaping +
WalkSegments) in the proxy service's JWT middleware with
github.com/jmespath-community/go-jmespath. extractRoles in oidcroles.go
and readUserIDClaim in account_resolver.go now uses jmespath.Search()
NOTE: This change is backwards-incompatible for some corner cases. While
simple dot-separated paths like 'realm_access.roles' are unchanged,
claim paths containing literal dots (i.e. where the dot does not
indicate a hierarchy) must now be quoted ('"sub.roles"' instead of
'sub\.roles').
74dc6f8 to
0687bd2
Compare
|
There was a problem hiding this comment.
Pull Request Overview
This PR aims to refactor the proxy's JWT claim extraction to use JMESPath. While this improves query flexibility, the following issues prevent a complete review and safe merge:
- Missing Code Changes: The review analysis detected an empty diff, making it impossible to verify the logic in
oidcroles.goandaccount_resolver.goor the removal of legacy functions. - Breaking Change: The transition to JMESPath requires literal dots in claim paths to be enclosed in double quotes. This will break existing configurations that rely on the previous escaping mechanism.
- Test Coverage Gap: No unit or integration tests were provided to validate the new extraction logic, specifically for nested roles and literal dot scenarios.
- Acceptance Criteria Unverified: Due to the missing code, verification of the core implementation requirements is currently blocked.
About this PR
- The pull request context provided for review does not contain the actual code changes. Please ensure the commits are pushed and the diff is available for verification.
- This refactor introduces a breaking change: claim paths containing literal dots now require double-quoted JMESPath syntax (e.g., '"sub.id"'). Ensure this change is documented and that a migration path or notice is provided for existing configurations.
Test suggestions
- Extract nested roles using standard dot notation (e.g., 'realm_access.roles')
- Extract claims containing literal dots using new quoted syntax (e.g., '"sub.id"')
- Handle invalid JMESPath expressions during claim extraction
- Verify removal of legacy SplitWithEscaping and WalkSegments utility functions
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Extract nested roles using standard dot notation (e.g., 'realm_access.roles')
2. Extract claims containing literal dots using new quoted syntax (e.g., '"sub.id"')
3. Handle invalid JMESPath expressions during claim extraction
4. Verify removal of legacy SplitWithEscaping and WalkSegments utility functions
TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback
Up to standards ✅🟢 Issues
|
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.



Replace the custom dot-path walking implementation (SplitWithEscaping + WalkSegments) in the proxy service's JWT middleware with github.com/jmespath-community/go-jmespath. extractRoles in oidcroles.go and readUserIDClaim in account_resolver.go now uses jmespath.Search()
NOTE: This change is backwards-incompatible for some corner cases. While simple dot-separated paths like 'realm_access.roles' are unchanged, claim paths containing literal dots (i.e. where the dot does not indicate a hierarchy) must now be quoted ('"sub.roles"' instead of 'sub.roles').