-
Notifications
You must be signed in to change notification settings - Fork 288
Enhanced JWT Token Claim ValueType handling for Authorization Policies #1010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
…onciseness combined some methods as split was unnecessary) and refactored for adherance to current engine behavior to not look for legacy claimTypes with URIs (ADFS/XML claimtypes)
…w behavior of a "Try" prefixed method name. Added unit tests for each JSON ClaimValue type that would be present after SecurityJwtHandler parses valid JWT token and validates how policies are processed into OData compatible strings.
7 tasks
Aniruddh25
reviewed
Dec 3, 2022
Aniruddh25
approved these changes
Dec 3, 2022
ayush3797
approved these changes
Dec 5, 2022
Contributor
ayush3797
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
ayush3797
approved these changes
Dec 5, 2022
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.
Why make this change?
{ "identityProvider": "test", "userId": "12345", "userDetails": "john@contoso.com", "userRoles": ["role1", "role2", "author"], "claims": [{ "typ": "SeriesId", "val": 10000 }] }valueTypeis supplied by a value the .NET library- System.IdentityModel.Tokens.Jwt infers from the JSON type in the JWT token:Claimobject has a property ofvalueType, our Authorization policy processing functionality must take into account that claims will not always be of type "string". While we had some processing of various non-string types, the additional typesClaimValueTypes.UInteger32,ClaimValueTypes.UInteger64:,ClaimValueTypes.Integer,JsonClaimValueTypes.JsonNullwere added for completeness inGetODataCompliantClaimValue(Claim claim)in AuthorizationResolver.cs.userName.@claims.name eq @item.usernameGetODataCompliantClaimValue()method is responsible for knowing that the claimnameis of valueType string, so then the policy is resolved as:'myGitHubUsernameeq username` (@item removed as it denotes a reference to a database column).What is this change?
In addition to the OData Authorization policy processing of claim value types described above, some related but needed changes are included:
TryProcessDBPolicytoProcessDBPolicybecause method does not use the "try" semantics.How was this tested?