Merge "django22: Add 'request' as first argument to 'authenticate'"
This commit is contained in:
commit
a96c6e34cf
@ -33,6 +33,8 @@ LOG = logging.getLogger(__name__)
|
|||||||
KEYSTONE_CLIENT_ATTR = "_keystoneclient"
|
KEYSTONE_CLIENT_ATTR = "_keystoneclient"
|
||||||
|
|
||||||
|
|
||||||
|
# TODO(stephenfin): Subclass 'django.contrib.auth.backends.BaseBackend' once we
|
||||||
|
# (only) support Django 3.0
|
||||||
class KeystoneBackend(object):
|
class KeystoneBackend(object):
|
||||||
"""Django authentication backend for use with ``django.contrib.auth``."""
|
"""Django authentication backend for use with ``django.contrib.auth``."""
|
||||||
|
|
||||||
@ -99,7 +101,7 @@ class KeystoneBackend(object):
|
|||||||
'configuration error that should be addressed.')
|
'configuration error that should be addressed.')
|
||||||
raise exceptions.KeystoneAuthException(msg)
|
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."""
|
"""Authenticates a user via the Keystone Identity API."""
|
||||||
LOG.debug('Beginning user authentication')
|
LOG.debug('Beginning user authentication')
|
||||||
|
|
||||||
@ -117,7 +119,6 @@ class KeystoneBackend(object):
|
|||||||
|
|
||||||
# the recent project id a user might have set in a cookie
|
# the recent project id a user might have set in a cookie
|
||||||
recent_project = None
|
recent_project = None
|
||||||
request = kwargs.get('request')
|
|
||||||
if request:
|
if request:
|
||||||
# Grab recent_project found in the cookie, try to scope
|
# Grab recent_project found in the cookie, try to scope
|
||||||
# to the last project used.
|
# to the last project used.
|
||||||
|
@ -161,7 +161,7 @@ def websso(request):
|
|||||||
auth_url = utils.clean_up_auth_url(referer)
|
auth_url = utils.clean_up_auth_url(referer)
|
||||||
token = request.POST.get('token')
|
token = request.POST.get('token')
|
||||||
try:
|
try:
|
||||||
request.user = auth.authenticate(request=request, auth_url=auth_url,
|
request.user = auth.authenticate(request, auth_url=auth_url,
|
||||||
token=token)
|
token=token)
|
||||||
except exceptions.KeystoneAuthException as exc:
|
except exceptions.KeystoneAuthException as exc:
|
||||||
if utils.is_websso_default_redirect():
|
if utils.is_websso_default_redirect():
|
||||||
@ -330,7 +330,7 @@ def switch_keystone_provider(request, keystone_provider=None,
|
|||||||
if unscoped_auth_ref:
|
if unscoped_auth_ref:
|
||||||
try:
|
try:
|
||||||
request.user = auth.authenticate(
|
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)
|
token=unscoped_auth_ref.auth_token)
|
||||||
except exceptions.KeystoneAuthException as exc:
|
except exceptions.KeystoneAuthException as exc:
|
||||||
msg = 'Keystone provider switch failed: %s' % six.text_type(exc)
|
msg = 'Keystone provider switch failed: %s' % six.text_type(exc)
|
||||||
|
Loading…
Reference in New Issue
Block a user