Skip to content

Commit

Permalink
Merge "Retrieve user_id from HTTP Headers to populate Context"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Feb 13, 2014
2 parents e00c41b + b839a44 commit 8c4adee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion heat/common/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class RequestContext(context.RequestContext):
"""

def __init__(self, auth_token=None, username=None, password=None,
aws_creds=None, tenant=None,
aws_creds=None, tenant=None, user_id=None,
tenant_id=None, auth_url=None, roles=None, is_admin=None,
read_only=False, show_deleted=False,
overwrite=True, trust_id=None, trustor_user_id=None,
Expand All @@ -55,6 +55,7 @@ def __init__(self, auth_token=None, username=None, password=None,
request_id=request_id)

self.username = username
self.user_id = user_id
self.password = password
self.aws_creds = aws_creds
self.tenant_id = tenant_id
Expand Down Expand Up @@ -84,6 +85,7 @@ def session(self):
def to_dict(self):
return {'auth_token': self.auth_token,
'username': self.username,
'user_id': self.user_id,
'password': self.password,
'aws_creds': self.aws_creds,
'tenant': self.tenant,
Expand Down Expand Up @@ -131,11 +133,13 @@ def process_request(self, req):

try:
username = None
user_id = None
password = None
aws_creds = None

if headers.get('X-Auth-User') is not None:
username = headers.get('X-Auth-User')
user_id = headers.get('X-User-Id')
password = headers.get('X-Auth-Key')
elif headers.get('X-Auth-EC2-Creds') is not None:
aws_creds = headers.get('X-Auth-EC2-Creds')
Expand All @@ -155,6 +159,7 @@ def process_request(self, req):
tenant=tenant, tenant_id=tenant_id,
aws_creds=aws_creds,
username=username,
user_id=user_id,
password=password,
auth_url=auth_url, roles=roles)

Expand Down
2 changes: 2 additions & 0 deletions heat/tests/test_common_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def setUp(self):
'show_deleted': False,
'roles': ['arole', 'notadmin'],
'tenant_id': '456tenant',
'user_id': 'fooUser',
'tenant': 'atenant',
'auth_url': 'http://xyz',
'aws_creds': 'blah'}
Expand All @@ -47,6 +48,7 @@ def test_request_context_init(self):
aws_creds=self.ctx.get('aws_creds'),
tenant=self.ctx.get('tenant'),
tenant_id=self.ctx.get('tenant_id'),
user_id=self.ctx.get('user_id'),
auth_url=self.ctx.get('auth_url'),
roles=self.ctx.get('roles'),
show_deleted=self.ctx.get('show_deleted'),
Expand Down

0 comments on commit 8c4adee

Please sign in to comment.