summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorMichael Gundlach <michael.gundlach@rackspace.com>2010-11-30 19:09:38 +0000
committerTarmac <>2010-11-30 19:09:38 +0000
commit29ffb1d27b32e9b71fc436a142e0c4601251c398 (patch)
treef4afb27b6e32a9d086fb99527ac98bb12e7ef067 /nova/api
parent2d8c15257b6860d107c24a2a7321d713f709d066 (diff)
parent84fdd48fe2db20661f076884810f0c726630452f (diff)
OpenStack API returns the wrong x-server-management-url. Fix that.
Fixes https://bugs.launchpad.net/nova/+bug/680709 .
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/auth.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/nova/api/openstack/auth.py b/nova/api/openstack/auth.py
index ff428ff70..205035915 100644
--- a/nova/api/openstack/auth.py
+++ b/nova/api/openstack/auth.py
@@ -23,10 +23,7 @@ class Context(object):
class BasicApiAuthManager(object):
""" Implements a somewhat rudimentary version of OpenStack Auth"""
- def __init__(self, host=None, db_driver=None):
- if not host:
- host = FLAGS.host
- self.host = host
+ def __init__(self, db_driver=None):
if not db_driver:
db_driver = FLAGS.db_driver
self.db = utils.import_object(db_driver)
@@ -47,7 +44,7 @@ class BasicApiAuthManager(object):
except KeyError:
return faults.Fault(webob.exc.HTTPUnauthorized())
- token, user = self._authorize_user(username, key)
+ token, user = self._authorize_user(username, key, req)
if user and token:
res = webob.Response()
res.headers['X-Auth-Token'] = token.token_hash
@@ -82,8 +79,13 @@ class BasicApiAuthManager(object):
return {'id': user.id}
return None
- def _authorize_user(self, username, key):
- """ Generates a new token and assigns it to a user """
+ def _authorize_user(self, username, key, req):
+ """Generates a new token and assigns it to a user.
+
+ username - string
+ key - string API key
+ req - webob.Request object
+ """
user = self.auth.get_user_from_access_key(key)
if user and user.name == username:
token_hash = hashlib.sha1('%s%s%f' % (username, key,
@@ -91,12 +93,10 @@ class BasicApiAuthManager(object):
token_dict = {}
token_dict['token_hash'] = token_hash
token_dict['cdn_management_url'] = ''
- token_dict['server_management_url'] = self._get_server_mgmt_url()
+ # Same as auth url, e.g. http://foo.org:8774/baz/v1.0
+ token_dict['server_management_url'] = req.url
token_dict['storage_url'] = ''
token_dict['user_id'] = user.id
token = self.db.auth_create_token(self.context, token_dict)
return token, user
return None, None
-
- def _get_server_mgmt_url(self):
- return 'https://%s/v1.0/' % self.host