Merge "Fix django.contrib.auth.middleware monkey patching" into stable/queens
This commit is contained in:
commit
93fceeefa3
|
@ -63,6 +63,7 @@ INSTALLED_APPS = (
|
|||
)
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'openstack_auth.middleware.OpenstackAuthMonkeyPatchMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from openstack_auth import utils
|
||||
|
||||
# NOTE: The main role of this middleware is to call this.
|
||||
utils.patch_middleware_get_user()
|
||||
|
||||
|
||||
class OpenstackAuthMonkeyPatchMiddleware(object):
|
||||
pass
|
|
@ -28,6 +28,7 @@ INSTALLED_APPS = [
|
|||
]
|
||||
|
||||
MIDDLEWARE_CLASSES = [
|
||||
'openstack_auth.middleware.OpenstackAuthMonkeyPatchMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
|
|
|
@ -15,13 +15,9 @@ from django.conf.urls import include
|
|||
from django.conf.urls import url
|
||||
from django.views import generic
|
||||
|
||||
from openstack_auth import utils
|
||||
from openstack_auth import views
|
||||
|
||||
|
||||
utils.patch_middleware_get_user()
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r"", include('openstack_auth.urls')),
|
||||
url(r"^websso/$", views.websso, name='websso'),
|
||||
|
|
|
@ -16,8 +16,6 @@ from django.conf.urls import url
|
|||
from openstack_auth import utils
|
||||
from openstack_auth import views
|
||||
|
||||
utils.patch_middleware_get_user()
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r"^login/$", views.login, name='login'),
|
||||
|
|
|
@ -37,8 +37,8 @@ We need the request object to get the user, so we'll slightly modify the
|
|||
existing django.contrib.auth.get_user method. To do so we update the
|
||||
auth middleware to point to our overridden method.
|
||||
|
||||
Calling the "patch_middleware_get_user" method somewhere like our urls.py
|
||||
file takes care of hooking it in appropriately.
|
||||
Calling "patch_middleware_get_user" is done in our custom middleware at
|
||||
"openstack_auth.middleware" to monkeypatch the code in before it is needed.
|
||||
"""
|
||||
|
||||
|
||||
|
|
|
@ -108,6 +108,7 @@ OPENSTACK_IMAGE_BACKEND = {
|
|||
}
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'openstack_auth.middleware.OpenstackAuthMonkeyPatchMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
|
|
|
@ -466,7 +466,6 @@ class APITestCase(TestCase):
|
|||
"""
|
||||
def setUp(self):
|
||||
super(APITestCase, self).setUp()
|
||||
utils.patch_middleware_get_user()
|
||||
|
||||
def fake_keystoneclient(request, admin=False):
|
||||
"""Returns the stub keystoneclient.
|
||||
|
|
Loading…
Reference in New Issue