Auth: also support Bearer token authentication

This is commonly used in OAuth-authenticated calls, and can help us break
away from the username-is-auth-token stuff currently in use.
This commit is contained in:
2017-12-08 14:46:58 +01:00
parent 3ea2504e8c
commit 199c6b1f77

View File

@@ -118,9 +118,13 @@ def validate_token():
from pillar.auth import AnonymousUser
auth_header = request.headers.get('Authorization') or ''
if request.authorization:
token = request.authorization.username
oauth_subclient = request.authorization.password
elif auth_header.startswith('Bearer '):
token = auth_header[7:].strip()
oauth_subclient = ''
else:
# Check the session, the user might be logged in through Flask-Login.
from pillar import auth