diff options
author | Gordon Chung <chungg@ca.ibm.com> | 2013-02-21 15:52:12 -0500 |
---|---|---|
committer | Gordon Chung <chungg@ca.ibm.com> | 2013-03-07 17:06:38 -0500 |
commit | dd7d4fd551f727873462d3ef2ece863ab6400995 (patch) | |
tree | 67032fdfcd41e89ef63b5541c116f22055ab5990 /keystone/auth | |
parent | 2b49a0ad13a4aca086474f101b104ac562e1f2f0 (diff) | |
download | keystone-dd7d4fd551f727873462d3ef2ece863ab6400995.tar.gz keystone-dd7d4fd551f727873462d3ef2ece863ab6400995.tar.xz keystone-dd7d4fd551f727873462d3ef2ece863ab6400995.zip |
return 201 Created on POST request (bug1131119)
correct status code from 200 Ok to 201 Created for v3 POST requests.
Fixes: bug #1131119
Change-Id: Iabeb6daf677e0f34defdef5e58d87229fc90346f
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, |