-
Notifications
You must be signed in to change notification settings - Fork 6k
Improve handling of non-String principal claim values #9212
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
Comments
@omlip I agree that we should avoid a I think adding |
@jgrandja Sure I will, you can assign it to me |
Thanks @omlip ! |
@jgrandja PR submitted Sould not we, by the way, adjust the documentation to mention that it is possible to set manually a principalClaimName and that must be a String ? |
Thanks @omlip. Agreed, please update the javadoc for |
Ok will update the PR accordingly. |
Hi @jgrandja I was talking about Spring Security Reference documentation.
to be transformed in something like this :
but also I can update javadoc of course :-) What do you think ? br |
Sounds good @omlip |
Context
When configuring an Spring application as an OAuth Resource Server and we use Jwt, we can set manually the
principalClaimName
on JwtAuthenticationConverter object.Example like this
Current Behavior
If we use a specific
principalClaimName
on a JwtAuthenticationConverter and if the value behind the claim name is not a String, a ClassCastException is thrown in the convert method.We can easily reproduce the situation by adding a test in class
JwtAuthenticationConverterTests
.Expected Behavior
I think we should adapt the code to not lead to a ClassCastException but maybe throw a proper exception which "explain" what the problem is.
Maybe by adapting like this ?
or maybe with the usage of Jwt.claimAsString(...) method ?
What do you think ?
Let me know if I can help.
PS : by the way, regarding this RFC https://tools.ietf.org/html/rfc7519#section-4.1.2 about JWT token, nothing say that a claim value must be a String as it is implemented in JwtAuthenticationToken. Maybe this discussion is out of scope but indeed
Best regards,
Olivier
The text was updated successfully, but these errors were encountered: