summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Santa Barbara <justin@fathomdb.com>2010-07-19 21:38:57 -0700
committerJustin Santa Barbara <justin@fathomdb.com>2010-07-19 21:38:57 -0700
commitf507cdf99d0bd5adfc2c1c1b265f192de119160f (patch)
tree65ee7ea8f0e586ad122a927da379d0cd7d950a08
parenta232ba0fda12a98e9da4345a6911a86b68f91826 (diff)
parent8625275e14d40dd82d19d2273e14f82334c6b5ac (diff)
downloadnova-f507cdf99d0bd5adfc2c1c1b265f192de119160f.tar.gz
nova-f507cdf99d0bd5adfc2c1c1b265f192de119160f.tar.xz
nova-f507cdf99d0bd5adfc2c1c1b265f192de119160f.zip
Merged lp:~justin-fathomdb/nova/bug607501
-rw-r--r--nova/objectstore/handler.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/nova/objectstore/handler.py b/nova/objectstore/handler.py
index b2ed3d482..c670ee02f 100644
--- a/nova/objectstore/handler.py
+++ b/nova/objectstore/handler.py
@@ -103,13 +103,16 @@ def get_argument(request, key, default_value):
def get_context(request):
try:
# Authorization Header format: 'AWS <access>:<secret>'
- access, sep, secret = request.getHeader('Authorization').split(' ')[1].rpartition(':')
+ authorization_header = request.getHeader('Authorization')
+ if not authorization_header:
+ raise exception.NotAuthorized
+ access, sep, secret = authorization_header.split(' ')[1].rpartition(':')
um = users.UserManager.instance()
print 'um %s' % um
(user, project) = um.authenticate(access, secret, {}, request.method, request.host, request.uri, False)
# FIXME: check signature here!
return api.APIRequestContext(None, user, project)
- except exception.Error, ex:
+ except exception.Error as ex:
logging.debug("Authentication Failure: %s" % ex)
raise exception.NotAuthorized
@@ -165,7 +168,7 @@ class BucketResource(Resource):
logging.debug("Creating bucket %s" % (self.name))
try:
print 'user is %s' % request.context
- except Exception, e:
+ except Exception as e:
logging.exception(e)
logging.debug("calling bucket.Bucket.create(%r, %r)" % (self.name, request.context))
bucket.Bucket.create(self.name, request.context)
@@ -239,9 +242,10 @@ class ImageResource(Resource):
""" returns a json listing of all images
that a user has permissions to see """
- images = [i for i in image.Image.all() if i.is_authorized(self.context)]
+ images = [i for i in image.Image.all() if i.is_authorized(request.context)]
request.write(json.dumps([i.metadata for i in images]))
+ request.finish()
return server.NOT_DONE_YET
def render_PUT(self, request):