horizon/horizon
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
..
browsers Reproduce navigations on refreshing ngdetails view 2018-03-29 15:01:59 +09:00
conf Support simple FIP disassociation (with FIP release) 2018-04-08 07:29:54 +09:00
contrib Fix H405 (multi line docstring) warnings (horizon) 2017-06-09 16:04:57 +00:00
forms django2: Replace django.core.urlresolves with django.urls 2018-02-17 01:36:48 +09:00
hacking Eliminate mutable default arguments 2015-12-17 09:58:46 +00:00
locale Imported Translations from Zanata 2018-08-10 07:50:06 +00:00
management Rename pull_catalog args from version to branch 2018-04-05 14:54:28 +02:00
middleware Safer handling of return statement inside of OperationLogMiddleware 2018-08-15 15:29:34 +00:00
static Watch field item changes 2018-04-22 08:21:10 +08:00
tables Remove the redundant "required=True" 2018-07-23 09:42:41 +08:00
tabs TabGroup: Make tabs pluggable via horizon plugin config 2018-03-12 21:04:22 +09:00
templates Show WEBSSO disclaimer only when it is needed 2018-06-04 15:49:54 +03:00
templatetags Drop Django <= 1.10 support 2018-03-03 07:33:23 +09:00
test Fix django.contrib.auth.middleware monkey patching 2018-11-20 21:24:04 +09:00
utils Merge "Make babel_extract_angular work with python 3" 2018-05-07 19:37:24 +00:00
workflows Change catch type for workflow unregister 2018-06-11 17:17:18 +02:00
__init__.py Revert "Enable to refresh ngdetails view" 2017-08-02 18:31:22 +00:00
base.py Fix Angular errors in openstack_auth 2018-03-17 18:36:01 +09:00
context_processors.py Remove extraneous vim configuration comments 2014-05-06 15:30:10 +08:00
decorators.py django2: is_authenticated/is_anonymous is now property only 2018-02-17 01:36:54 +09:00
exceptions.py Correct odd exception message 2018-01-30 13:11:31 +09:00
karma.conf.js Makes the xstatic files lookup dynamic in the tests 2017-07-27 10:01:33 -04:00
loaders.py Django2: Use new custom template loader interface 2018-03-03 07:22:35 +09:00
messages.py hacking: noqa cleanup in horizon 2017-03-17 19:38:47 +00:00
notifications.py Fix W503 warnings 2018-04-11 18:13:47 +09:00
site_urls.py django2: Fix 3-tuple ImproperlyConfigured error 2018-03-03 07:20:43 +09:00
themes.py Django2: Use new custom template loader interface 2018-03-03 07:22:35 +09:00
version.py Remove extraneous vim configuration comments 2014-05-06 15:30:10 +08:00
views.py flake8-import-order: Ensure to place project imports last 2017-09-20 01:19:38 +00:00