horizon/openstack_dashboard
Mathieu Gagné 8851866aad Fix django.contrib.auth.middleware monkey patching
The "request" attribute is not available in
openstack_auth.backend.KeystoneBackend.get_user when session data is restored
and it's the first request to happen after a server restart.

As stated by the function document, the "request" attribute needs to be
monkey-patched by openstack_auth.utils.patch_middleware_get_user
for this function to work properly.

This should happen in openstack_auth.urls at import time. But there is nowhere
in Horizon where this module is imported at startup. It's only introspected
by openstack_dashboard.urls due to AUTHENTICATION_URLS setting.

Without this monkey-patching, the whole authentication mechanism falls back
to "AnonymousUser" and you will get redirected to the login page due
to horizon.exceptions.NotAuthenticated being raised by
horizon.decorators.require_auth as request.user.is_authenticated will be False.

But if a user requests a page under auth/, it will have the side-effect of
monkey-patching django.contrib.auth.middleware as expected. This means that
once this request is completed, all following requests to pages other than
the ones under auth/ will have there sessions properly restored and
you will be properly authenticated.

Therefore this change introduces a dummy middleware which sole purpose is
to perform this monkey-patching as early as possible.

There is also some cleanup to get rid of the previous attempts at
monkeypatching.

Closes-bug: #1764622

Conflicts:
	openstack_dashboard/settings.py
	openstack_dashboard/test/helpers.py

Change-Id: Ib9912090a87b716e7f5710f6f360b0df168ec2e3
(cherry picked from commit 0d16361326)
2018-11-20 21:24:04 +09:00
..
api Fix changing user's own password 2018-10-30 12:25:39 +00:00
conf Sync nova policy 2018-02-05 05:57:02 +09:00
contrib Delete profiler object when request completes 2018-07-24 12:33:31 +01:00
dashboards Add enabled check in Backups panel 2018-09-27 13:40:25 +00:00
django_pyscss_fix Handle log message interpolation by the logger 2017-03-31 20:59:16 +09:00
enabled Generic volume group support 2018-06-09 06:39:18 +00:00
local support WEBSSO_KEYSTONE_URL 2018-10-29 13:27:11 -07:00
locale Imported Translations from Zanata 2018-11-10 07:50:32 +00:00
management Create new wsgi.py file and deprecate old file 2018-05-15 01:41:01 +00:00
static Merge "Revert "Network Topology graph "twitches""" into stable/rocky 2018-08-21 13:18:05 +00:00
templates Remove deprecated table.UpdateAction class 2018-04-12 17:34:17 +03:00
templatetags django2: Replace assignment_tag with simple_tag 2018-02-17 01:36:54 +09:00
test Fix django.contrib.auth.middleware monkey patching 2018-11-20 21:24:04 +09:00
themes Drop unnecessary executable flags 2017-12-27 21:32:48 +00:00
usage Merge "quota: Move targets argument to get_disabled_quotas" 2018-05-16 16:59:31 +00:00
utils Merge "Workflow: Make steps pluggable via horizon plugin config" 2018-04-25 10:25:54 +00:00
wsgi Create new wsgi.py file and deprecate old file 2018-05-15 01:41:01 +00:00
.eslintrc Add selective ESLint rule activation for Horizon Legacy JS 2015-07-08 17:06:15 -07:00
__init__.py
context_processors.py Fix wrong setting name for SHOW_KEYSTONE_V2_RC 2018-03-21 07:20:31 +13:00
exceptions.py Drop Heat related code from horizon 2017-12-05 07:38:55 +00:00
hooks.py
karma.conf.js Makes the xstatic files lookup dynamic in the tests 2017-07-27 10:01:33 -04:00
policy.py Specify POLICY_CHECK_FUNCTION as a string 2016-11-25 13:06:14 +01:00
settings.py Fix django.contrib.auth.middleware monkey patching 2018-11-20 21:24:04 +09:00
theme_settings.py Drop deprecated settings 2018-03-23 18:37:02 +09:00
urls.py Fix Angular errors in openstack_auth 2018-03-17 18:36:01 +09:00
views.py force plain text for header response 2018-08-06 19:57:59 +03:00
wsgi.py Create new wsgi.py file and deprecate old file 2018-05-15 01:41:01 +00:00