summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormdietz <mdietz@openstack>2010-09-23 19:31:17 +0000
committermdietz <mdietz@openstack>2010-09-23 19:31:17 +0000
commitfc5d09f4d294b0c176a40632a1848a1069596375 (patch)
tree17f374f6af4ec5ac1ca4c6106f28006b07b1034b
parentca854c764a21985fd07becf7b0686f5d00125851 (diff)
parent378970b1495840a2a193dbecc3f9bb8701237744 (diff)
downloadnova-fc5d09f4d294b0c176a40632a1848a1069596375.tar.gz
nova-fc5d09f4d294b0c176a40632a1848a1069596375.tar.xz
nova-fc5d09f4d294b0c176a40632a1848a1069596375.zip
Merge fix from Soren
-rw-r--r--nova/api/rackspace/__init__.py25
-rw-r--r--nova/auth/manager.py2
-rw-r--r--nova/db/sqlalchemy/api.py41
3 files changed, 24 insertions, 44 deletions
diff --git a/nova/api/rackspace/__init__.py b/nova/api/rackspace/__init__.py
index 74bd1955f..c24d08585 100644
--- a/nova/api/rackspace/__init__.py
+++ b/nova/api/rackspace/__init__.py
@@ -71,31 +71,6 @@ class AuthMiddleware(wsgi.Middleware):
req.environ['nova.context'] = context
return self.application
- def authenticate(self, req):
- # Unless the request is explicitly made against /<version>/ don't
- # honor it
- path_info = req.environ['wsgiorg.routing_args'][1]['path_info']
- if path_info:
- return webob.exc.HTTPUnauthorized()
-
- if req.headers.has_key("X-Auth-User") and \
- req.headers.has_key("X-Auth-Key"):
- username, key = req.headers['X-Auth-User'], req.headers['X-Auth-Key']
- token, user = self.auth_driver.authorize_user(username, key)
- if user and token:
- res = webob.Response()
- res.headers['X-Auth-Token'] = token
- res.headers['X-Server-Management-Url'] = \
- user['server_management_url']
- res.headers['X-Storage-Url'] = user['storage_url']
- res.headers['X-CDN-Management-Url'] = user['cdn_management_url']
- res.content_type = 'text/plain'
- res.status = '204'
- return res
- else:
- return webob.exc.HTTPUnauthorized()
- return webob.exc.HTTPUnauthorized()
-
class RateLimitingMiddleware(wsgi.Middleware):
"""Rate limit incoming requests according to the OpenStack rate limits."""
diff --git a/nova/auth/manager.py b/nova/auth/manager.py
index bc3a8a12e..2ec586419 100644
--- a/nova/auth/manager.py
+++ b/nova/auth/manager.py
@@ -266,7 +266,7 @@ class AuthManager(object):
# NOTE(vish): if we stop using project name as id we need better
# logic to find a default project for user
- if project_id is '':
+ if project_id == '':
project_id = user.name
project = self.get_project(project_id)
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 0edfc5319..2b0dd6ea6 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -681,6 +681,29 @@ def export_device_create(_context, values):
###################
+def auth_destroy_token(_context, token):
+ session = get_session()
+ session.delete(token)
+
+def auth_get_token(_context, token_hash):
+ session = get_session()
+ tk = session.query(models.AuthToken
+ ).filter_by(token_hash=token_hash)
+ if not tk:
+ raise exception.NotFound('Token %s does not exist' % token_hash)
+ return tk
+
+def auth_create_token(_context, token):
+ tk = models.AuthToken()
+ for k,v in token.iteritems():
+ tk[k] = v
+ tk.save()
+ return tk
+
+
+###################
+
+
def quota_create(_context, values):
quota_ref = models.Quota()
for (key, value) in values.iteritems():
@@ -708,25 +731,7 @@ def quota_destroy(_context, project_id):
quota_ref = models.Quota.find_by_str(project_id, session=session)
quota_ref.delete(session=session)
-def auth_destroy_token(_context, token):
- session = get_session()
- session.delete(token)
-
-def auth_get_token(_context, token_hash):
- session = get_session()
- tk = session.query(models.AuthToken
- ).filter_by(token_hash=token_hash)
- if not tk:
- raise exception.NotFound('Token %s does not exist' % token_hash)
- return tk
-def auth_create_token(_context, token):
- tk = models.AuthToken()
- for k,v in token.iteritems():
- tk[k] = v
- tk.save()
- return tk
-
###################