Revert commit 709. This fixes issues with the Openstack API causing 'No user for access key admin' errors.

This commit is contained in:
Dan Prince 2011-02-24 00:34:55 +00:00 committed by Tarmac
commit 211810f9ea
3 changed files with 7 additions and 11 deletions

View File

@ -120,8 +120,8 @@ class AuthMiddleware(wsgi.Middleware):
req - webob.Request object
"""
ctxt = context.get_admin_context()
user = self.auth.get_user_from_access_key(username)
if user and user.secret == key:
user = self.auth.get_user_from_access_key(key)
if user and user.name == username:
token_hash = hashlib.sha1('%s%s%f' % (username, key,
time.time())).hexdigest()
token_dict = {}

View File

@ -221,8 +221,7 @@ class FakeAuthDatabase(object):
class FakeAuthManager(object):
auth_data = {}
def add_user(self, user):
key = user.id
def add_user(self, key, user):
FakeAuthManager.auth_data[key] = user
def get_user(self, uid):
@ -235,10 +234,7 @@ class FakeAuthManager(object):
return None
def get_user_from_access_key(self, key):
for k, v in FakeAuthManager.auth_data.iteritems():
if v.access == key:
return v
return None
return FakeAuthManager.auth_data.get(key, None)
class FakeRateLimiter(object):

View File

@ -48,7 +48,7 @@ class Test(unittest.TestCase):
def test_authorize_user(self):
f = fakes.FakeAuthManager()
f.add_user(nova.auth.manager.User(1, 'herp', 'herp', 'derp', None))
f.add_user('derp', nova.auth.manager.User(1, 'herp', None, None, None))
req = webob.Request.blank('/v1.0/')
req.headers['X-Auth-User'] = 'herp'
@ -62,7 +62,7 @@ class Test(unittest.TestCase):
def test_authorize_token(self):
f = fakes.FakeAuthManager()
f.add_user(nova.auth.manager.User(1, 'herp', 'herp', 'derp', None))
f.add_user('derp', nova.auth.manager.User(1, 'herp', None, None, None))
req = webob.Request.blank('/v1.0/', {'HTTP_HOST': 'foo'})
req.headers['X-Auth-User'] = 'herp'
@ -144,7 +144,7 @@ class TestLimiter(unittest.TestCase):
def test_authorize_token(self):
f = fakes.FakeAuthManager()
f.add_user(nova.auth.manager.User(1, 'herp', 'herp', 'derp', None))
f.add_user('derp', nova.auth.manager.User(1, 'herp', None, None, None))
req = webob.Request.blank('/v1.0/')
req.headers['X-Auth-User'] = 'herp'