-
Notifications
You must be signed in to change notification settings - Fork 317
Raise AuthenticationCredentialsNotFoundException if Principal is not present and declared as not optional #790
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
Conversation
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.
This looks good so far. However, we also have AuthenticationPrincipalArgumentResolver
that probably needs a similar update.
Updated it to reuse the |
ea4d766
to
1f1ac3c
Compare
1f1ac3c
to
cb7b8dc
Compare
This is now processed, thanks for the changes! I've made some small adjustments, notably to treat |
Great! Although I didn't expect this to get merged right away, and I think it might need some additional tests for the |
You can submit a PR in draft mode in that case. Overall seems alright to me. The resolver for |
The issue with a non-null principal argument is more visible in Kotlin then it is in Java; in Java even when a function argument is annotated as non-null, it still accepts a null value for that parameter, but in Kotlin this results in a "can not assign null to non-null parameter" error.
By throwing a security error when the argument is non-null, and the principal isn't present in the security context, authentication errors can be handler in an exception resolver class, instead of resulting in an arbitrary internal error.
Fixes #714