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