Raise AuthenticationCredentialsNotFoundException if Principal is not present and declared as not optional#790
Conversation
rstoyanchev
left a comment
There was a problem hiding this comment.
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