def on_route(self, state): headers = state.request.headers roles = headers.get('X-Roles', '').split(',') is_admin = policy.check_is_admin(roles) creds = { 'user': headers.get('X-User') or headers.get('X-User-Id'), 'tenant': headers.get('X-Tenant') or headers.get('X-Tenant-Id'), 'auth_token': headers.get('X-Auth-Token'), 'is_admin': is_admin, 'roles': roles, } state.request.context = context.RequestContext(**creds)
def _extend_request_context(): headers = flask.request.headers roles = headers.get('X-Roles', '').split(',') is_admin = policy.check_is_admin(roles) ctx = { 'user_id': headers.get('X-User-Id', ''), 'auth_token': headers.get('X-Auth-Token', ''), 'is_admin': is_admin, 'roles': roles, 'project_id': headers.get('X-Project-Id', ''), 'domain_id': headers.get('X-Domain-Id', ''), } flask.request.context = context.RequestContext(**ctx)
def on_route(self, state): headers = state.request.headers roles = headers.get('X-Roles', '').split(',') is_admin = policy.check_is_admin(roles) creds = { 'user': headers.get('X-User-Id', ''), 'tenant': headers.get('X-Tenant-Id', ''), 'auth_token': headers.get('X-Auth-Token', ''), 'is_admin': is_admin, 'roles': roles, "user_name": headers.get('X-User-Name', ''), "project_name": headers.get('X-Project-Name', ''), "domain": headers.get('X-User-Domain-Id', ''), "domain_name": headers.get('X-User-Domain-Name', ''), } state.request.context = context.RequestContext(**creds)
def on_route(self, state): headers = state.request.headers roles = headers.get('X-Roles', '').split(',') is_admin = policy.check_is_admin(roles) creds = { 'user_id': headers.get('X-User-Id', ''), 'tenant': headers.get('X-Tenant-Id', ''), 'auth_token': headers.get('X-Auth-Token', ''), 'is_admin': is_admin, 'roles': roles, "user_name": headers.get('X-User-Name', ''), "project_name": headers.get('X-Project-Name', ''), "domain": headers.get('X-User-Domain-Id', ''), "domain_name": headers.get('X-User-Domain-Name', ''), } state.request.context = context.RequestContext(**creds)
def __init__(self, is_admin=None, **kwargs): super(RequestContext, self).__init__(is_admin=is_admin, **kwargs) if self.is_admin is None: self.is_admin = policy.check_is_admin(self)