Fix RequestContext attributes
'auth_url', 'auth_token_info' and 'trust_id' is required to create heatclient. So this commit added these. Change-Id: If17c87770f2e4d93dae5e1262faa5b44cc5cfdef
This commit is contained in:
parent
f2a657eefe
commit
2e7b9046a8
@ -17,6 +17,7 @@ import re
|
|||||||
|
|
||||||
from keystonemiddleware import auth_token
|
from keystonemiddleware import auth_token
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
from oslo.utils import importutils
|
||||||
from pecan import hooks
|
from pecan import hooks
|
||||||
|
|
||||||
from magnum.common import context
|
from magnum.common import context
|
||||||
@ -102,6 +103,7 @@ class AuthInformationHook(hooks.PecanHook):
|
|||||||
tenant = state.request.headers.get('X-Tenant', tenant)
|
tenant = state.request.headers.get('X-Tenant', tenant)
|
||||||
domain_id = state.request.headers.get('X-User-Domain-Id')
|
domain_id = state.request.headers.get('X-User-Domain-Id')
|
||||||
domain_name = state.request.headers.get('X-User-Domain-Name')
|
domain_name = state.request.headers.get('X-User-Domain-Name')
|
||||||
|
auth_token_info = state.request.environ.get('keystone.token_info')
|
||||||
|
|
||||||
# Get the auth token
|
# Get the auth token
|
||||||
try:
|
try:
|
||||||
@ -111,19 +113,21 @@ class AuthInformationHook(hooks.PecanHook):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
LOG.debug("No auth token found in the request.")
|
LOG.debug("No auth token found in the request.")
|
||||||
raise Exception('Not authorized')
|
raise Exception('Not authorized')
|
||||||
# auth_url = headers.get('X-Auth-Url')
|
auth_url = headers.get('X-Auth-Url')
|
||||||
# if auth_url is None:
|
if auth_url is None:
|
||||||
# importutils.import_module('keystonemiddleware.auth_token')
|
importutils.import_module('keystonemiddleware.auth_token')
|
||||||
# auth_url = cfg.CONF.keystone_authtoken.auth_uri
|
auth_url = cfg.CONF.keystone_authtoken.auth_uri
|
||||||
|
|
||||||
identity_status = headers.get('X-Identity-Status')
|
identity_status = headers.get('X-Identity-Status')
|
||||||
if identity_status == 'Confirmed':
|
if identity_status == 'Confirmed':
|
||||||
ctx = context.RequestContext(auth_token=recv_auth_token,
|
ctx = context.RequestContext(auth_token=recv_auth_token,
|
||||||
|
auth_url=auth_url,
|
||||||
|
auth_token_info=auth_token_info,
|
||||||
user=user_id,
|
user=user_id,
|
||||||
tenant=tenant,
|
tenant=tenant,
|
||||||
domain_id=domain_id,
|
domain_id=domain_id,
|
||||||
domain_name=domain_name)
|
domain_name=domain_name)
|
||||||
state.request.security_context = ctx
|
state.request.context = ctx
|
||||||
else:
|
else:
|
||||||
LOG.debug("The provided identity is not confirmed.")
|
LOG.debug("The provided identity is not confirmed.")
|
||||||
raise Exception('Not authorized. Identity not confirmed.')
|
raise Exception('Not authorized. Identity not confirmed.')
|
||||||
|
@ -18,9 +18,10 @@ from oslo_context import context
|
|||||||
class RequestContext(context.RequestContext):
|
class RequestContext(context.RequestContext):
|
||||||
"""Extends security contexts from the OpenStack common library."""
|
"""Extends security contexts from the OpenStack common library."""
|
||||||
|
|
||||||
def __init__(self, auth_token=None, domain_id=None, domain_name=None,
|
def __init__(self, auth_token=None, auth_url=None, domain_id=None,
|
||||||
user=None, tenant=None, is_admin=False, is_public_api=False,
|
domain_name=None, user=None, tenant=None, is_admin=False,
|
||||||
read_only=False, show_deleted=False, request_id=None):
|
is_public_api=False, read_only=False, show_deleted=False,
|
||||||
|
request_id=None, trust_id=None, auth_token_info=None):
|
||||||
"""Stores several additional request parameters:
|
"""Stores several additional request parameters:
|
||||||
|
|
||||||
:param domain_id: The ID of the domain.
|
:param domain_id: The ID of the domain.
|
||||||
@ -32,6 +33,9 @@ class RequestContext(context.RequestContext):
|
|||||||
self.is_public_api = is_public_api
|
self.is_public_api = is_public_api
|
||||||
self.domain_id = domain_id
|
self.domain_id = domain_id
|
||||||
self.domain_name = domain_name
|
self.domain_name = domain_name
|
||||||
|
self.auth_url = auth_url
|
||||||
|
self.auth_token_info = auth_token_info
|
||||||
|
self.trust_id = trust_id
|
||||||
|
|
||||||
super(RequestContext, self).__init__(auth_token=auth_token,
|
super(RequestContext, self).__init__(auth_token=auth_token,
|
||||||
user=user, tenant=tenant,
|
user=user, tenant=tenant,
|
||||||
|
Loading…
Reference in New Issue
Block a user