summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorMonsyne Dragon <mdragon@rackspace.com>2011-03-08 17:18:13 +0000
committerMonsyne Dragon <mdragon@rackspace.com>2011-03-08 17:18:13 +0000
commitcbc2956a4e863c1bc952c7cef6045c39d293818d (patch)
tree092344a0253d5ca017f9ff80be7706d0609d0dfe /nova/api
parent417f6ca5c54878a6bea4d545126f93ecb6a043b4 (diff)
downloadnova-cbc2956a4e863c1bc952c7cef6045c39d293818d.tar.gz
nova-cbc2956a4e863c1bc952c7cef6045c39d293818d.tar.xz
nova-cbc2956a4e863c1bc952c7cef6045c39d293818d.zip
Remove addition of account to service url.
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/__init__.py24
-rw-r--r--nova/api/openstack/auth.py46
2 files changed, 13 insertions, 57 deletions
diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py
index 005d330a6..a655b1c85 100644
--- a/nova/api/openstack/__init__.py
+++ b/nova/api/openstack/__init__.py
@@ -73,18 +73,6 @@ class APIRouter(wsgi.Router):
def __init__(self):
mapper = routes.Mapper()
- accounts_controller = accounts.Controller()
- mapper.connect("account", "/{id}",
- controller=accounts_controller, action="show",
- conditions=dict(method=["GET"]))
- if FLAGS.allow_admin_api:
- mapper.connect("/{id}",
- controller=accounts_controller, action="update",
- conditions=dict(method=["PUT"]))
- mapper.connect("/{id}",
- controller=accounts_controller, action="delete",
- conditions=dict(method=["DELETE"]))
-
server_members = {'action': 'POST'}
if FLAGS.allow_admin_api:
LOG.debug(_("Including admin operations in API."))
@@ -101,38 +89,34 @@ class APIRouter(wsgi.Router):
server_members['inject_network_info'] = 'POST'
mapper.resource("zone", "zones", controller=zones.Controller(),
- path_prefix="{account_id}/",
collection={'detail': 'GET'})
mapper.resource("user", "users", controller=users.Controller(),
- path_prefix="{account_id}/",
collection={'detail': 'GET'})
+ mapper.resource("account", "accounts",
+ controller=accounts.Controller(),
+ collection={'detail': 'GET'})
+
mapper.resource("server", "servers", controller=servers.Controller(),
collection={'detail': 'GET'},
- path_prefix="{account_id}/",
member=server_members)
mapper.resource("backup_schedule", "backup_schedule",
controller=backup_schedules.Controller(),
- path_prefix="{account_id}/servers/{server_id}/",
parent_resource=dict(member_name='server',
collection_name='servers'))
mapper.resource("console", "consoles",
controller=consoles.Controller(),
- path_prefix="{account_id}/servers/{server_id}/",
parent_resource=dict(member_name='server',
collection_name='servers'))
mapper.resource("image", "images", controller=images.Controller(),
- path_prefix="{account_id}/",
collection={'detail': 'GET'})
mapper.resource("flavor", "flavors", controller=flavors.Controller(),
- path_prefix="{account_id}/",
collection={'detail': 'GET'})
mapper.resource("shared_ip_group", "shared_ip_groups",
- path_prefix="{account_id}/",
collection={'detail': 'GET'},
controller=shared_ip_groups.Controller())
diff --git a/nova/api/openstack/auth.py b/nova/api/openstack/auth.py
index e77910fed..e71fc69e3 100644
--- a/nova/api/openstack/auth.py
+++ b/nova/api/openstack/auth.py
@@ -53,19 +53,15 @@ class AuthMiddleware(wsgi.Middleware):
if not self.has_authentication(req):
return self.authenticate(req)
user = self.get_user_by_authentication(req)
- account_name = req.path_info_peek()
-
+ accounts = self.auth.get_projects(user=user)
if not user:
return faults.Fault(webob.exc.HTTPUnauthorized())
- if not account_name:
- if self.auth.is_admin(user):
- account_name = FLAGS.default_project
- else:
- return faults.Fault(webob.exc.HTTPUnauthorized())
- try:
- account = self.auth.get_project(account_name)
- except exception.NotFound:
+ 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())
if not self.auth.is_admin(user) and \
@@ -85,7 +81,6 @@ class AuthMiddleware(wsgi.Middleware):
# Unless the request is explicitly made against /<version>/ don't
# honor it
path_info = req.path_info
- account_name = None
if len(path_info) > 1:
return faults.Fault(webob.exc.HTTPUnauthorized())
@@ -95,10 +90,7 @@ class AuthMiddleware(wsgi.Middleware):
except KeyError:
return faults.Fault(webob.exc.HTTPUnauthorized())
- if ':' in username:
- account_name, username = username.rsplit(':', 1)
-
- token, user = self._authorize_user(username, account_name, key, req)
+ token, user = self._authorize_user(username, key, req)
if user and token:
res = webob.Response()
res.headers['X-Auth-Token'] = token.token_hash
@@ -135,31 +127,15 @@ class AuthMiddleware(wsgi.Middleware):
return self.auth.get_user(token.user_id)
return None
- def _authorize_user(self, username, account_name, key, req):
+ def _authorize_user(self, username, key, req):
"""Generates a new token and assigns it to a user.
username - string
- account_name - string
key - string API key
req - webob.Request object
"""
ctxt = context.get_admin_context()
user = self.auth.get_user_from_access_key(key)
- if account_name:
- try:
- account = self.auth.get_project(account_name)
- except exception.NotFound:
- return None, None
- else:
- # (dragondm) punt and try to determine account.
- # this is something of a hack, but a user on 1 account is a
- # common case, and is the way the current RS code works.
- accounts = self.auth.get_projects(user=user)
- if len(accounts) == 1:
- account = accounts[0]
- else:
- #we can't tell what account they are logging in for.
- return None, None
if user and user.name == username:
token_hash = hashlib.sha1('%s%s%f' % (username, key,
@@ -167,11 +143,7 @@ class AuthMiddleware(wsgi.Middleware):
token_dict = {}
token_dict['token_hash'] = token_hash
token_dict['cdn_management_url'] = ''
- # auth url + project (account) id, e.g.
- # http://foo.org:8774/baz/v1.0/myacct/
- os_url = '%s%s%s/' % (req.url,
- '' if req.url.endswith('/') else '/',
- account.id)
+ os_url = req.url
token_dict['server_management_url'] = os_url
token_dict['storage_url'] = ''
token_dict['user_id'] = user.id