Example test showing the minimalist response to an empty Authorizatio… #16976
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.
…n header
relates to #16977
We recently had an application request fail to provide any bearer token in the Authorization header. They received a 401 as expected. However, the
www-authenticate
response header only had the wordBearer
in the value. This made it difficult to debug as it implied that they were sending a bearer token when they weren't.I suggest an improvement in Spring Security to add an error message such as
missing_token
or some other similar value to help identify the root problem.This PR contains a test case that will pass when the additional error message is provided.
I am willing to provide a fix for this as well. However, I don't know where in Spring Security to implement such a fix. I know about
BearerTokenAuthenticationEntryPoint
where other bearer token related errors have their details added. However, that doesn't feel right in this case because we aren't 100% guaranteed the intent of the request was to provide a bearer token (some other form of Authorization may be supported along with OAuth2 Resource Server).