Fixed support for "Bearer" and "Token" auth-schemes.

Removed the test for "Authentication: Bearer Token <TOKEN>" which was not supposed to exist (see https://github.com/channelcat/sanic/pull/821)
Also added a call to `split` when retrieving the token value to handle cases where there are leading or trailing spaces.
This commit is contained in:
François KUBLER
2017-06-29 10:23:49 +02:00
parent d2e14abfd5
commit 1f24abc3d2
2 changed files with 2 additions and 12 deletions

View File

@@ -86,13 +86,13 @@ class Request(dict):
:return: token related to request
"""
prefixes = ('Bearer', 'Token ')
prefixes = ('Bearer', 'Token')
auth_header = self.headers.get('Authorization')
if auth_header is not None:
for prefix in prefixes:
if prefix in auth_header:
return auth_header.partition(prefix)[-1]
return auth_header.partition(prefix)[-1].strip()
return auth_header