From 02f4d8ab762cd8587873e832bdcb8e4c1ec0656c Mon Sep 17 00:00:00 2001 From: Hemanth Nakkina Date: Mon, 9 Dec 2019 14:59:59 +0530 Subject: [PATCH] Fix users/projects list when domain context is changed In case of Keystone Multidomain setup, the project and users list is empty when the domain context is changed. Horizon uses domain scoped token for keystone api calls to get list of projects and users. And domain scoped token cannot get information about projects and users in other domains, the list is empty. This patch modifies the use of domain scoped token only when domain context is not modified. The bug have 3 parts 1. Users are not listed on GUI in different domain 2. Projects are not listed on GUI in different domain 3. Gui hangs during creation of user/project using + option This patch handles case 1 and 2. Change-Id: Ibafe3e2eb3ee1ee5c9eb5d2a276a0edfa3e7c607 Partial-Bug: #1826114 Closes-Bug: #1830782 (cherry picked from commit 9aca7a94e28589484e312770cc1ee2b8243211bb) --- openstack_dashboard/api/keystone.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openstack_dashboard/api/keystone.py b/openstack_dashboard/api/keystone.py index cbf2da107d..af3d779ba5 100644 --- a/openstack_dashboard/api/keystone.py +++ b/openstack_dashboard/api/keystone.py @@ -149,8 +149,12 @@ def keystoneclient(request, admin=False): token_id = user.token.id if is_multi_domain_enabled(): - # Cloud Admin, Domain Admin or Mixed Domain Admin - if is_domain_admin(request): + is_domain_context_specified = bool( + request.session.get("domain_context")) + + # If user is Cloud Admin, Domain Admin or Mixed Domain Admin and there + # is no domain context specified, use domain scoped token + if is_domain_admin(request) and not is_domain_context_specified: domain_token = request.session.get('domain_token') if domain_token: token_id = getattr(domain_token, 'auth_token', None)