diff options
Diffstat (limited to 'keystone/auth')
-rw-r--r-- | keystone/auth/controllers.py | 4 | ||||
-rw-r--r-- | keystone/auth/token_factory.py | 9 |
2 files changed, 9 insertions, 4 deletions
diff --git a/keystone/auth/controllers.py b/keystone/auth/controllers.py index 96f3dc0c..ec532b1b 100644 --- a/keystone/auth/controllers.py +++ b/keystone/auth/controllers.py @@ -294,8 +294,8 @@ class Auth(controller.V3Controller): auth_context) (token_id, token_data) = token_factory.create_token( context, auth_context, auth_info) - return token_factory.render_token_data_response(token_id, - token_data) + return token_factory.render_token_data_response( + token_id, token_data, created=True) except (exception.Unauthorized, exception.AuthMethodNotSupported, exception.AdditionalAuthRequired) as e: diff --git a/keystone/auth/token_factory.py b/keystone/auth/token_factory.py index 8460aec6..4d5c0b87 100644 --- a/keystone/auth/token_factory.py +++ b/keystone/auth/token_factory.py @@ -294,7 +294,7 @@ def create_token(context, auth_context, auth_info): return (token_id, token_data) -def render_token_data_response(token_id, token_data): +def render_token_data_response(token_id, token_data, created=False): """ Render token data HTTP response. Stash token ID into the X-Auth-Token header. @@ -303,7 +303,12 @@ def render_token_data_response(token_id, token_data): headers = [('X-Subject-Token', token_id)] headers.append(('Vary', 'X-Auth-Token')) headers.append(('Content-Type', 'application/json')) - status = (200, 'OK') + + if created: + status = (201, 'Created') + else: + status = (200, 'OK') + body = jsonutils.dumps(token_data, cls=utils.SmarterEncoder) return webob.Response(body=body, status='%s %s' % status, |