diff --git a/openstack_auth/backend.py b/openstack_auth/backend.py index 8116cabcec..2a46584a26 100644 --- a/openstack_auth/backend.py +++ b/openstack_auth/backend.py @@ -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. diff --git a/openstack_auth/views.py b/openstack_auth/views.py index 1fbf556440..7dcfc5eee2 100644 --- a/openstack_auth/views.py +++ b/openstack_auth/views.py @@ -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)