context: add auth token to context
For tacker server to call other openstack servers like nova Change-Id: I52bd64e2aea61ab3a9307351ef943fdf7a6074bf
This commit is contained in:
parent
54f088cfc1
commit
3a6367e295
|
@ -50,10 +50,14 @@ class TackerKeystoneContext(wsgi.Middleware):
|
|||
# Use request_id if already set
|
||||
req_id = req.environ.get(request_id.ENV_REQUEST_ID)
|
||||
|
||||
# Get the auth token
|
||||
auth_token = req.headers.get('X_AUTH_TOKEN',
|
||||
req.headers.get('X_STORAGE_TOKEN'))
|
||||
|
||||
# Create a context with the authentication data
|
||||
ctx = context.Context(user_id, tenant_id, roles=roles,
|
||||
user_name=user_name, tenant_name=tenant_name,
|
||||
request_id=req_id)
|
||||
request_id=req_id, auth_token=auth_token)
|
||||
|
||||
# Inject the context...
|
||||
req.environ['tacker.context'] = ctx
|
||||
|
|
|
@ -41,7 +41,7 @@ class ContextBase(common_context.RequestContext):
|
|||
def __init__(self, user_id, tenant_id, is_admin=None, read_deleted="no",
|
||||
roles=None, timestamp=None, load_admin_roles=True,
|
||||
request_id=None, tenant_name=None, user_name=None,
|
||||
overwrite=True, **kwargs):
|
||||
overwrite=True, auth_token=None, **kwargs):
|
||||
"""Object initialization.
|
||||
|
||||
:param read_deleted: 'no' indicates deleted records are hidden, 'yes'
|
||||
|
@ -56,7 +56,8 @@ class ContextBase(common_context.RequestContext):
|
|||
"""
|
||||
super(ContextBase, self).__init__(user=user_id, tenant=tenant_id,
|
||||
is_admin=is_admin,
|
||||
request_id=request_id)
|
||||
request_id=request_id,
|
||||
auth_token=auth_token)
|
||||
self.user_name = user_name
|
||||
self.tenant_name = tenant_name
|
||||
|
||||
|
@ -132,6 +133,7 @@ class ContextBase(common_context.RequestContext):
|
|||
'tenant_name': self.tenant_name,
|
||||
'project_name': self.tenant_name,
|
||||
'user_name': self.user_name,
|
||||
'auth_token': self.auth_token,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
|
Loading…
Reference in New Issue