Skip to content
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

trim whitespaces from the token before validation check #433

Closed
wants to merge 1 commit into from
Closed

trim whitespaces from the token before validation check #433

wants to merge 1 commit into from

Conversation

mx-jhinz
Copy link

Sometimes users accidentally pass sanctum tokens in the request header with leading or trailing white-spaces (two white-spaces between the word "Bearer" and the token), like in:

curl  -H 'accept: application/json' -H "Authorization: Bearer  <token>" 
curl  -H 'accept: application/json' -H "Authorization: Bearer <token> " 

Currently, this results in an unexpected 401 with {"message":"Unauthenticated."} response from the application even though the token is correct. This can confuse the user. In this change tokens from the $request with leading or trailing white-spaces should be trimmed such that correct token are accepted and not denied.

@driesvints
Copy link
Member

This is incorrect I feel. It's up to the sender to provide a correct bearer token.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants