Add support for www_authenticate_uri in ContextHook

* Added support for www_authenticate_uri in ContextHook.
* Made code path consistent with keystone.py impl.

Story: 2004271
Task: 28073

Change-Id: I7e3f23964a55be3255e87a4c4af7bae0a1415676
This commit is contained in:
Erik Olof Gunnar Andersson 2018-11-23 15:16:04 -08:00
parent b095d012e2
commit f27bde7171
1 changed files with 7 additions and 2 deletions

View File

@ -16,7 +16,8 @@ from pecan import hooks
from magnum.common import context
from magnum.conductor import api as conductor_api
import magnum.conf
import magnum.conf.keystone
CONF = magnum.conf.CONF
@ -57,7 +58,11 @@ class ContextHook(hooks.PecanHook):
roles = headers.get('X-Roles', '').split(',')
auth_token_info = state.request.environ.get('keystone.token_info')
auth_url = CONF.keystone_authtoken.auth_uri
conf = CONF[magnum.conf.keystone.CFG_LEGACY_GROUP]
auth_url = (getattr(conf, 'www_authenticate_uri', None) or
getattr(conf, 'auth_uri', None))
if auth_url:
auth_url = auth_url.replace('v2.0', 'v3')
state.request.context = context.make_context(
auth_token=auth_token,