Browse Source

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

tags/16.0.0.0b2
Zuul 1 week ago
parent
commit
a96c6e34cf
2 changed files with 5 additions and 4 deletions
  1. 3
    2
      openstack_auth/backend.py
  2. 2
    2
      openstack_auth/views.py

+ 3
- 2
openstack_auth/backend.py View File

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

+ 2
- 2
openstack_auth/views.py View File

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

Loading…
Cancel
Save