mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 05:29:26 -02:30
selectively authenticate with OAuth2 Backend
This commit is contained in:
@@ -46,14 +46,17 @@ class SessionAuthentication(authentication.SessionAuthentication):
|
|||||||
class LoggedOAuth2Authentication(OAuth2Authentication):
|
class LoggedOAuth2Authentication(OAuth2Authentication):
|
||||||
|
|
||||||
def authenticate(self, request):
|
def authenticate(self, request):
|
||||||
ret = super(LoggedOAuth2Authentication, self).authenticate(request)
|
if 'Bearer' in request.META['HTTP_AUTHORIZATION']:
|
||||||
if ret:
|
ret = super(LoggedOAuth2Authentication, self).authenticate(request)
|
||||||
user, token = ret
|
if ret:
|
||||||
username = user.username if user else '<none>'
|
user, token = ret
|
||||||
logger.info(smart_text(
|
username = user.username if user else '<none>'
|
||||||
u"User {} performed a {} to {} through the API using OAuth token {}.".format(
|
logger.debug(smart_text(
|
||||||
username, request.method, request.path, token.pk
|
u"User {} performed a {} to {} through the API using OAuth token {}.".format(
|
||||||
)
|
username, request.method, request.path, token.pk
|
||||||
))
|
)
|
||||||
setattr(user, 'oauth_scopes', [x for x in token.scope.split() if x])
|
))
|
||||||
return ret
|
setattr(user, 'oauth_scopes', [x for x in token.scope.split() if x])
|
||||||
|
return ret
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user