diff --git a/magnum/api/hooks.py b/magnum/api/hooks.py index ba9632d8c8..9839a6b5c2 100644 --- a/magnum/api/hooks.py +++ b/magnum/api/hooks.py @@ -28,8 +28,8 @@ class ContextHook(hooks.PecanHook): The following HTTP request headers are used: - X-User: - Used for context.user. + X-User-Name: + Used for context.user_name. X-User-Id: Used for context.user_id. @@ -47,14 +47,13 @@ class ContextHook(hooks.PecanHook): def before(self, state): headers = state.request.headers - user = headers.get('X-User') + user_name = headers.get('X-User-Name') user_id = headers.get('X-User-Id') project = headers.get('X-Project-Name') project_id = headers.get('X-Project-Id') domain_id = headers.get('X-User-Domain-Id') domain_name = headers.get('X-User-Domain-Name') - auth_token = headers.get('X-Storage-Token') - auth_token = headers.get('X-Auth-Token', auth_token) + auth_token = headers.get('X-Auth-Token') auth_token_info = state.request.environ.get('keystone.token_info') auth_url = headers.get('X-Auth-Url') @@ -66,7 +65,7 @@ class ContextHook(hooks.PecanHook): auth_token=auth_token, auth_url=auth_url, auth_token_info=auth_token_info, - user_name=user, + user_name=user_name, user_id=user_id, project_name=project, project_id=project_id, diff --git a/magnum/tests/unit/api/test_hooks.py b/magnum/tests/unit/api/test_hooks.py index 2bec645103..39939292f8 100644 --- a/magnum/tests/unit/api/test_hooks.py +++ b/magnum/tests/unit/api/test_hooks.py @@ -43,6 +43,8 @@ class TestContextHook(base.BaseTestCase): fakes.fakeAuthTokenHeaders['X-Auth-Token']) self.assertEqual(ctx.project_id, fakes.fakeAuthTokenHeaders['X-Project-Id']) + self.assertEqual(ctx.user_name, + fakes.fakeAuthTokenHeaders['X-User-Name']) self.assertEqual(ctx.user_id, fakes.fakeAuthTokenHeaders['X-User-Id']) self.assertEqual(ctx.auth_url,