-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: nested claims mapping in OAuth2 token validation #3814
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
base: main
Are you sure you want to change the base?
Conversation
Note: This would break the case where the top level key is an actual string with a ".", I'm wondering do we need to support both cases? |
can you add a validation to the config class? |
I'm not sure what could be validated at config/startup. We won't see the claims to know which it is until runtime, I can think of 3 options
|
I think option 3 is the best. Option 2 is ugly and pushes the problem into configuration. Option 1, i.e. not supporting dots in keys at all, seems too drastic. I think we could consider the dotted form and nested form 'equivalent'. It seems very unlikely that a given token would have separate claims, one nested and another with the equivalent dotted key, especially with different values. Supporting both does not require much more code and will 'just work' in every likely case. |
The get_attributes_from_claims function was only checking for top-level claim keys, causing token validation to fail when using nested claims like "resource_access.llamastack.roles" (common in Keycloak JWT tokens). Updated the function to support dot notation for traversing nested claim structures. Give precedence to dot notation over literal keys with dots in claims mapping. Added test coverage. Closes: llamastack#3812 Signed-off-by: Derek Higgins <derekh@redhat.com>
967c2b9
to
fc16b95
Compare
thanks @grs , I've updated the PR to support both with precedence to dot notation |
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
fix: nested claims mapping in OAuth2 token validation
The get_attributes_from_claims function was only checking for top-level
claim keys, causing token validation to fail when using nested claims
like "resource_access.llamastack.roles" (common in Keycloak JWT tokens).
Updated the function to support dot notation for traversing nested claim
structures. Give precedence to dot notation over literal keys with dots
in claims mapping.
Added test coverage.
Closes: #3812