From 94a34e0e69a520e403a2d8e579186fad9acf14c7 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Fri, 29 Jun 2012 21:32:08 -0600 Subject: Add ServiceCatalog entries to enable Cinder usage * Part of of blueprint extract-nova-volumes * Adds usage of service catalog to ec2 * Adds entries to auth.py * Implements tests for new authorization mods Change-Id: I2efb375bbb130cde6a1ba119fa862ca45b126a1e --- nova/api/auth.py | 8 +++++++- nova/api/ec2/__init__.py | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'nova/api') diff --git a/nova/api/auth.py b/nova/api/auth.py index 72eba1d9c..c0ea1680d 100644 --- a/nova/api/auth.py +++ b/nova/api/auth.py @@ -18,6 +18,7 @@ Common Auth Middleware. """ +import json import webob.dec import webob.exc @@ -95,13 +96,18 @@ class NovaKeystoneContext(wsgi.Middleware): remote_address = req.remote_addr if FLAGS.use_forwarded_for: remote_address = req.headers.get('X-Forwarded-For', remote_address) + + if req.headers.get('X_SERVICE_CATALOG') is not None: + service_catalog = json.loads(req.headers.get('X_SERVICE_CATALOG')) + ctx = context.RequestContext(user_id, project_id, user_name=user_name, project_name=project_name, roles=roles, auth_token=auth_token, - remote_address=remote_address) + remote_address=remote_address, + service_catalog=service_catalog) req.environ['nova.context'] = ctx return self.application diff --git a/nova/api/ec2/__init__.py b/nova/api/ec2/__init__.py index 6bb19e7b3..d21c575cd 100644 --- a/nova/api/ec2/__init__.py +++ b/nova/api/ec2/__init__.py @@ -261,13 +261,16 @@ class EC2KeystoneAuth(wsgi.Middleware): if FLAGS.use_forwarded_for: remote_address = req.headers.get('X-Forwarded-For', remote_address) + + catalog = result['access']['serviceCatalog'] ctxt = context.RequestContext(user_id, project_id, user_name=user_name, project_name=project_name, roles=roles, auth_token=token_id, - remote_address=remote_address) + remote_address=remote_address, + service_catalog=catalog) req.environ['nova.context'] = ctxt -- cgit