Merge "django22: Add 'request' as first argument to 'authenticate'"

This commit is contained in:
Zuul 2019-09-10 20:48:56 +00:00 committed by Gerrit Code Review
commit a96c6e34cf
2 changed files with 5 additions and 4 deletions

View File

@ -33,6 +33,8 @@ LOG = logging.getLogger(__name__)
KEYSTONE_CLIENT_ATTR = "_keystoneclient"
# TODO(stephenfin): Subclass 'django.contrib.auth.backends.BaseBackend' once we
# (only) support Django 3.0
class KeystoneBackend(object):
"""Django authentication backend for use with ``django.contrib.auth``."""
@ -99,7 +101,7 @@ class KeystoneBackend(object):
'configuration error that should be addressed.')
raise exceptions.KeystoneAuthException(msg)
def authenticate(self, auth_url=None, **kwargs):
def authenticate(self, request, auth_url=None, **kwargs):
"""Authenticates a user via the Keystone Identity API."""
LOG.debug('Beginning user authentication')
@ -117,7 +119,6 @@ class KeystoneBackend(object):
# the recent project id a user might have set in a cookie
recent_project = None
request = kwargs.get('request')
if request:
# Grab recent_project found in the cookie, try to scope
# to the last project used.

View File

@ -161,7 +161,7 @@ def websso(request):
auth_url = utils.clean_up_auth_url(referer)
token = request.POST.get('token')
try:
request.user = auth.authenticate(request=request, auth_url=auth_url,
request.user = auth.authenticate(request, auth_url=auth_url,
token=token)
except exceptions.KeystoneAuthException as exc:
if utils.is_websso_default_redirect():
@ -330,7 +330,7 @@ def switch_keystone_provider(request, keystone_provider=None,
if unscoped_auth_ref:
try:
request.user = auth.authenticate(
request=request, auth_url=unscoped_auth.auth_url,
request, auth_url=unscoped_auth.auth_url,
token=unscoped_auth_ref.auth_token)
except exceptions.KeystoneAuthException as exc:
msg = 'Keystone provider switch failed: %s' % six.text_type(exc)