From 2f2222daf8550ba4c396cc52be37dae1324a8593 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Wed, 19 Oct 2016 09:36:28 +1100 Subject: [PATCH] Allow POLICY_CHECK_FUNCTION to be disabled Remove the current defaulting behaviour when it is set to None. Change-Id: If8e018414f9f348980d0783f90afa039330e0e49 Closes-Bug: 1634677 --- doc/source/topics/policy.rst | 3 ++- openstack_dashboard/settings.py | 19 ++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/doc/source/topics/policy.rst b/doc/source/topics/policy.rst index 9a9c676251..21a03a1332 100644 --- a/doc/source/topics/policy.rst +++ b/doc/source/topics/policy.rst @@ -66,7 +66,8 @@ files containing a "default" rule would be ambiguous. Default: ``policy.check`` This value should not be changed, although removing it would be a means to -bypass all policy checks. +bypass all policy checks. Set it to ``None`` in ``local_settings.py`` to +do this. How user's roles are determined diff --git a/openstack_dashboard/settings.py b/openstack_dashboard/settings.py index 3e2c1a8cc6..800fee0454 100644 --- a/openstack_dashboard/settings.py +++ b/openstack_dashboard/settings.py @@ -297,7 +297,14 @@ THEME_COLLECTION_DIR = 'themes' # Theme Cookie Name THEME_COOKIE_NAME = 'theme' -POLICY_CHECK_FUNCTION = None + +def check(actions, request, target=None): + # Note(Itxaka): This is to prevent circular dependencies and apps not ready + # If you do django imports in your settings, you are gonna have a bad time + from openstack_auth import policy + return policy.check(actions, request, target) + +POLICY_CHECK_FUNCTION = check CSRF_COOKIE_AGE = None @@ -428,16 +435,6 @@ settings_utils.update_dashboards( ) INSTALLED_APPS[0:0] = ADD_INSTALLED_APPS - -def check(actions, request, target=None): - # Note(Itxaka): This is to prevent circular dependencies and apps not ready - # If you do django imports in your settings, you are gonna have a bad time - from openstack_auth import policy - return policy.check(actions, request, target) - -if POLICY_CHECK_FUNCTION is None: - POLICY_CHECK_FUNCTION = check - NG_TEMPLATE_CACHE_AGE = NG_TEMPLATE_CACHE_AGE if not DEBUG else 0 # This base context objects gets added to the offline context generator