From 69eb05ae712b8142d698ffa6c446816b76995f9a Mon Sep 17 00:00:00 2001 From: Elvin Tubillara Date: Wed, 31 Aug 2016 17:11:31 -0500 Subject: [PATCH] Keystone to Keystone Federation Drop Down This adds a dropdown to enable the user to switch Keystone providers using Keystone to Keystone Federation. Depends-On: I75b1a10a3b40b5544b60f6fdc060e0070c585977 Change-Id: Id39bf8d21c537347cbd23f63eaa3da8cc1bfff46 Implements: blueprint k2k-horizon --- .../common/_keystone_provider_selector.html | 20 +++++++++++++++ openstack_dashboard/context_processors.py | 25 +++++++++++++++++++ .../local/local_settings.py.example | 8 ++++++ .../templates/header/_header.html | 1 + .../header/_keystone_provider_selection.html | 11 ++++++++ .../bp-k2k-horizon-9577253d626337c1.yaml | 11 ++++++++ 6 files changed, 76 insertions(+) create mode 100644 horizon/templates/horizon/common/_keystone_provider_selector.html create mode 100644 openstack_dashboard/templates/header/_keystone_provider_selection.html create mode 100644 releasenotes/notes/bp-k2k-horizon-9577253d626337c1.yaml diff --git a/horizon/templates/horizon/common/_keystone_provider_selector.html b/horizon/templates/horizon/common/_keystone_provider_selector.html new file mode 100644 index 0000000000..5fc2fa1603 --- /dev/null +++ b/horizon/templates/horizon/common/_keystone_provider_selector.html @@ -0,0 +1,20 @@ +{% load i18n %} +{% if keystone_providers.support %} + + +{% endif %} diff --git a/openstack_dashboard/context_processors.py b/openstack_dashboard/context_processors.py index b5d4a7a766..10326b2cfd 100644 --- a/openstack_dashboard/context_processors.py +++ b/openstack_dashboard/context_processors.py @@ -55,6 +55,31 @@ def openstack(request): 'name': request.session.get('region_name')}, 'available': [{'endpoint': region[0], 'name':region[1]} for region in available_regions]} + + # K2K Federation Service Providers context/support + available_providers = request.session.get('keystone_providers', []) + if available_providers: + provider_id = request.session.get('keystone_provider_id', None) + provider_name = None + for provider in available_providers: + if provider['id'] == provider_id: + provider_name = provider.get('name') + + keystone_providers = { + 'support': len(available_providers) > 1, + 'current': { + 'name': provider_name, + 'id': provider_id + }, + 'available': [ + {'name': keystone_provider['name'], + 'id': keystone_provider['id']} + for keystone_provider in available_providers] + } + else: + keystone_providers = {'support': False} + + context['keystone_providers'] = keystone_providers context['regions'] = regions # Adding webroot access diff --git a/openstack_dashboard/local/local_settings.py.example b/openstack_dashboard/local/local_settings.py.example index ed8e6b7553..736d74b88a 100644 --- a/openstack_dashboard/local/local_settings.py.example +++ b/openstack_dashboard/local/local_settings.py.example @@ -196,6 +196,14 @@ OPENSTACK_KEYSTONE_DEFAULT_ROLE = "_member_" # "acme_saml2": ("acme", "saml2"), #} +# The Keystone Provider drop down uses Keystone to Keystone federation +# to switch between Keystone service providers. +# Set display name for Identity Provider (dropdown display name) +#KEYSTONE_PROVIDER_IDP_NAME = "Local Keystone" +# This id is used for only for comparison with the service provider IDs. This ID +# should not match any service provider IDs. +#KEYSTONE_PROVIDER_IDP_ID = "localkeystone" + # Disable SSL certificate checks (useful for self-signed certificates): #OPENSTACK_SSL_NO_VERIFY = True diff --git a/openstack_dashboard/templates/header/_header.html b/openstack_dashboard/templates/header/_header.html index 88518eab77..c1aa83357b 100644 --- a/openstack_dashboard/templates/header/_header.html +++ b/openstack_dashboard/templates/header/_header.html @@ -32,6 +32,7 @@ {% if profiler_enabled %} {% include "developer/profiler/_mode_picker.html" %} {% endif %} + {% include "header/_keystone_provider_selection.html" %} {% include "header/_user_menu.html" %} {% include "header/_region_selection.html" %} diff --git a/openstack_dashboard/templates/header/_keystone_provider_selection.html b/openstack_dashboard/templates/header/_keystone_provider_selection.html new file mode 100644 index 0000000000..9737e0f88d --- /dev/null +++ b/openstack_dashboard/templates/header/_keystone_provider_selection.html @@ -0,0 +1,11 @@ +{% if not_list %} + +{% else %} + +{% endif %} \ No newline at end of file diff --git a/releasenotes/notes/bp-k2k-horizon-9577253d626337c1.yaml b/releasenotes/notes/bp-k2k-horizon-9577253d626337c1.yaml new file mode 100644 index 0000000000..ec90e72b83 --- /dev/null +++ b/releasenotes/notes/bp-k2k-horizon-9577253d626337c1.yaml @@ -0,0 +1,11 @@ +--- +features: + - Added Keystone to Keystone (K2K) federation support in Horizon. If Keystone + is configured with K2K and has service providers, the list of + Keystone providers will appear in a dropdown. In local_settings.py you can + optionally set the identity provider display name with + ``KEYSTONE_PROVIDER_IDP_NAME`` or set the provider id that is used to + compare with the other service providers ``KEYSTONE_PROVIDER_IDP_ID``. + + [`blueprint k2k-horizon + `_].