diff options
| author | Lvov Maxim <usrleon@gmail.com> | 2011-06-01 16:40:19 +0400 |
|---|---|---|
| committer | Lvov Maxim <usrleon@gmail.com> | 2011-06-01 16:40:19 +0400 |
| commit | 5b45d5477cfff946ada581676db54fb254be6522 (patch) | |
| tree | efd51410dbab75743305b596e14b26bdc772ee4c /nova/api | |
| parent | a8113ae0dcc15171d138f6333203d0d16a24c8ea (diff) | |
osapi: added support for header X-Auth-Project-Id
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/auth.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/nova/api/openstack/auth.py b/nova/api/openstack/auth.py index 6c6ee22a2..e220ffcc2 100644 --- a/nova/api/openstack/auth.py +++ b/nova/api/openstack/auth.py @@ -50,19 +50,21 @@ class AuthMiddleware(wsgi.Middleware): if not self.has_authentication(req): return self.authenticate(req) user = self.get_user_by_authentication(req) - accounts = self.auth.get_projects(user=user) if not user: token = req.headers["X-Auth-Token"] msg = _("%(user)s could not be found with token '%(token)s'") LOG.warn(msg % locals()) return faults.Fault(webob.exc.HTTPUnauthorized()) - if accounts: - #we are punting on this til auth is settled, - #and possibly til api v1.1 (mdragon) - account = accounts[0] - else: - return faults.Fault(webob.exc.HTTPUnauthorized()) + try: + account = req.headers["X-Auth-Project-Id"] + except KeyError: + # FIXME: It needed only for compatibility + accounts = self.auth.get_projects(user=user) + if accounts: + account = accounts[0] + else: + return faults.Fault(webob.exc.HTTPUnauthorized()) if not self.auth.is_admin(user) and \ not self.auth.is_project_member(user, account): |
