def process_request(self, request): headers = request.headers try: if headers['X-Identity-Status'] is 'Invalid': #TODO(graham) fix the return to use non-flask resources return flask.Response(status=401) except KeyError: #If the key is valid, Keystone does not include this header at all pass 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) # Store the context where oslo-log exepcts to find it. local.store.context = context # Attempt to sudo, if requested. sudo_tenant_id = headers.get('X-Designate-Sudo-Tenant-ID', None) if sudo_tenant_id and (uuidutils.is_uuid_like(sudo_tenant_id) or sudo_tenant_id.isdigit()): context.sudo(sudo_tenant_id) # Attach the context to the request environment request.environ['context'] = context
def process_request(self, request): headers = request.headers 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) # Store the context where oslo-log exepcts to find it. local.store.context = context # Attempt to sudo, if requested. sudo_tenant_id = headers.get('X-Designate-Sudo-Tenant-ID', None) if sudo_tenant_id and (uuidutils.is_uuid_like(sudo_tenant_id) or sudo_tenant_id.isdigit()): context.sudo(sudo_tenant_id) # Attach the context to the request environment request.environ['context'] = context
def process_request(self, request): headers = request.headers try: if headers["X-Identity-Status"] is "Invalid": # TODO(graham) fix the return to use non-flask resources return flask.Response(status=401) except KeyError: # 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, service_catalog=catalog, ) # Store the context where oslo-log exepcts to find it. local.store.context = context # Attempt to sudo, if requested. sudo_tenant_id = headers.get("X-Designate-Sudo-Tenant-ID", None) if sudo_tenant_id and (uuidutils.is_uuid_like(sudo_tenant_id) or sudo_tenant_id.isdigit()): context.sudo(sudo_tenant_id) # Attach the context to the request environment request.environ["context"] = context
def to_python(self, value): if not uuidutils.is_uuid_like(value): raise ValidationError() return value