From 3388c37be1da37257fa6bbda17f7013f748cbcc5 Mon Sep 17 00:00:00 2001 From: Endre Karlson Date: Fri, 22 Nov 2013 09:23:46 +0100 Subject: [PATCH] Pass the service-catalog if any to the context Change-Id: Idc005b39f28a0fd30058d263643a44c777682f35 --- designate/api/middleware.py | 8 +++++++- designate/context.py | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/designate/api/middleware.py b/designate/api/middleware.py index 0c245f614..e64295d5d 100644 --- a/designate/api/middleware.py +++ b/designate/api/middleware.py @@ -108,12 +108,18 @@ class KeystoneContextMiddleware(ContextMiddleware): #If the key is valid, Keystone does not include this header at all pass + if headers.get('X-Service-Catalog'): + catalog = json.loads(headers.get('X-Service-Catalog')) + else: + catalog = None + roles = headers.get('X-Roles').split(',') context = DesignateContext(auth_token=headers.get('X-Auth-Token'), user=headers.get('X-User-ID'), tenant=headers.get('X-Tenant-ID'), - roles=roles) + roles=roles, + service_catalog=catalog) # Store the context where oslo-log exepcts to find it. local.store.context = context diff --git a/designate/context.py b/designate/context.py index 968e72ed7..c8a29001c 100644 --- a/designate/context.py +++ b/designate/context.py @@ -24,7 +24,7 @@ LOG = logging.getLogger(__name__) class DesignateContext(context.RequestContext): def __init__(self, auth_token=None, user=None, tenant=None, is_admin=False, read_only=False, show_deleted=False, request_id=None, - roles=[]): + roles=[], service_catalog=None): super(DesignateContext, self).__init__( auth_token=auth_token, user=user, @@ -36,6 +36,7 @@ class DesignateContext(context.RequestContext): self._original_tenant_id = None self.roles = roles + self.service_catalog = service_catalog def sudo(self, tenant_id, force=False): if force: @@ -65,6 +66,7 @@ class DesignateContext(context.RequestContext): 'tenant_id': self.tenant_id, 'original_tenant_id': self.original_tenant_id, 'roles': self.roles, + 'service_catalog': self.service_catalog }) return d