From b0e696cf9a79d9f17293347358de8c2fdfebdfe5 Mon Sep 17 00:00:00 2001 From: Amelia Cordwell Date: Fri, 1 Dec 2017 13:02:53 +1300 Subject: [PATCH] Optional removal of V2 openrc file * Setting 'SHOW_V2_KEYSTONE_RC' added and will control whether or not user's are able to see links for the V2 rc file on both the API Access panel and the user menu. Change-Id: I454fcf578dd8c4d2b9b52c3a9e5426b85e5298b5 --- doc/source/configuration/settings.rst | 10 ++++++++++ openstack_dashboard/context_processors.py | 1 + .../dashboards/project/api_access/tables.py | 4 ++++ .../local/local_settings.py.example | 5 +++++ openstack_dashboard/settings.py | 2 ++ .../templates/header/_user_menu.html | 15 ++++++++------- 6 files changed, 30 insertions(+), 7 deletions(-) diff --git a/doc/source/configuration/settings.rst b/doc/source/configuration/settings.rst index d5dee1bf54..5049d07468 100644 --- a/doc/source/configuration/settings.rst +++ b/doc/source/configuration/settings.rst @@ -844,6 +844,16 @@ This SESSION_TIMEOUT is a method to supercede the token timeout with a shorter horizon session timeout (in seconds). So if your token expires in 60 minutes, a value of 1800 will log users out after 30 minutes. +SHOW_KEYSTONE_V2_RC +-------------------- + +.. versionadded:: 13.0.0(Queens) + +Default: ``True`` + +Controls whether the keystone v2 openrc file is accessable from the user +menu and the api access panel. + THEME_COLLECTION_DIR -------------------- diff --git a/openstack_dashboard/context_processors.py b/openstack_dashboard/context_processors.py index 0a490a0428..1aa74e30ea 100644 --- a/openstack_dashboard/context_processors.py +++ b/openstack_dashboard/context_processors.py @@ -97,6 +97,7 @@ def openstack(request): hmac_keys, parent_id=index_view_id) context['JS_CATALOG'] = get_js_catalog(conf) + context['SHOW_KEYSTONE_V2_RC'] = settings.SHOW_KEYSTONE_V2_RC return context diff --git a/openstack_dashboard/dashboards/project/api_access/tables.py b/openstack_dashboard/dashboards/project/api_access/tables.py index cddddc14e6..17e274f6ab 100644 --- a/openstack_dashboard/dashboards/project/api_access/tables.py +++ b/openstack_dashboard/dashboards/project/api_access/tables.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +from django.conf import settings from django.template.defaultfilters import title from django.utils.translation import ugettext_lazy as _ @@ -70,6 +71,9 @@ class DownloadOpenRCv2(tables.LinkAction): icon = "download" url = "horizon:project:api_access:openrcv2" + def allowed(self, request, datum=None): + return settings.SHOW_KEYSTONE_V2_RC + class ViewCredentials(tables.LinkAction): name = "view_credentials" diff --git a/openstack_dashboard/local/local_settings.py.example b/openstack_dashboard/local/local_settings.py.example index 8f63dbe8bf..fd02631bac 100644 --- a/openstack_dashboard/local/local_settings.py.example +++ b/openstack_dashboard/local/local_settings.py.example @@ -108,6 +108,11 @@ WEBROOT = '/' # or None. Set to None explicitly if you want to deactivate the console. #CONSOLE_TYPE = "AUTO" +# Toggle showing the openrc file for Keystone V2. +# If set to false the link will be removed from the user dropdown menu +# and the API Access page +#SHOW_KEYSTONE_V2_RC = True + # If provided, a "Report Bug" link will be displayed in the site header # which links to the value of this setting (ideally a URL containing # information on how to report issues). diff --git a/openstack_dashboard/settings.py b/openstack_dashboard/settings.py index 06f8aed3d4..e2f7261482 100644 --- a/openstack_dashboard/settings.py +++ b/openstack_dashboard/settings.py @@ -323,6 +323,8 @@ CSRF_COOKIE_AGE = None COMPRESS_OFFLINE_CONTEXT = 'horizon.themes.offline_context' +SHOW_KEYSTONE_V2_RC = True + # Dictionary of currently available angular features ANGULAR_FEATURES = { 'images_panel': True, diff --git a/openstack_dashboard/templates/header/_user_menu.html b/openstack_dashboard/templates/header/_user_menu.html index 1f7d7f41d2..4601f21017 100644 --- a/openstack_dashboard/templates/header/_user_menu.html +++ b/openstack_dashboard/templates/header/_user_menu.html @@ -34,12 +34,14 @@ {% endif %} -
  • - - - {% trans "OpenStack RC File v2" %} - -
  • + {% if SHOW_KEYSTONE_V2_RC %} +
  • + + + {% trans "OpenStack RC File v2" %} + +
  • + {% endif %}
  • @@ -66,4 +68,3 @@ {% else %}
  • {% endif %} -