-
I spent a lot of time trying to investigate the message I was seeing in the logs about bearer not authenticated. It as correctly manifested on the client side as a 401 unauthorized exception, however with debug logs enabled on the server, I would have expected more detailed information about what was going wrong. All that is logged when a bearer is presented in the wrong format in the header is a sequence of debug messages about the bearer not authenticated, followed by authorization failed, and bearer was challenged. You can easily reproduce this with a simple spa front end where you send back the token with the token presented in the format Bearer: ey....., or yet still, just the token without the Bearer key work in front. One could argue that it's correct in this instance just to report this scenario as an authorization failure, however whilst developing and with debug logs turned on, I would expect a bit more information to help with resolving the underlying issue. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
If you're not sending the correct header format then the JWT middleware isn't going to pick up the token, in fact no authentication service is going to handle it, so there are notdetailed error messages to give, because nothing is doing anything with it. We can't say "Oh wrong format", because we don't know what the right formats are, given all the auth services stand alone, we just know nothing processed it. The lack of processing messages is probably the only clue here. |
Beta Was this translation helpful? Give feedback.
If you're not sending the correct header format then the JWT middleware isn't going to pick up the token, in fact no authentication service is going to handle it, so there are notdetailed error messages to give, because nothing is doing anything with it. We can't say "Oh wrong format", because we don't know what the right formats are, given all the auth services stand alone, we just know nothing processed it. The lack of processing messages is probably the only clue here.