Merge "Use to_policy_values for policy credentials"
This commit is contained in:
@@ -88,6 +88,11 @@ class RequestContext(context.RequestContext):
|
|||||||
'all_tenants': self.all_tenants})
|
'all_tenants': self.all_tenants})
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
def to_policy_values(self):
|
||||||
|
policy = super(RequestContext, self).to_policy_values()
|
||||||
|
policy['is_admin'] = self.is_admin
|
||||||
|
return policy
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls, values):
|
def from_dict(cls, values):
|
||||||
return cls(**values)
|
return cls(**values)
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ def enforce(context, rule=None, target=None,
|
|||||||
expression.
|
expression.
|
||||||
"""
|
"""
|
||||||
enforcer = init()
|
enforcer = init()
|
||||||
credentials = context.to_dict()
|
credentials = context.to_policy_values()
|
||||||
if not exc:
|
if not exc:
|
||||||
exc = exception.PolicyNotAuthorized
|
exc = exception.PolicyNotAuthorized
|
||||||
if target is None:
|
if target is None:
|
||||||
@@ -142,5 +142,5 @@ def check_is_admin(context):
|
|||||||
"""
|
"""
|
||||||
init()
|
init()
|
||||||
target = {}
|
target = {}
|
||||||
credentials = context.to_dict()
|
credentials = context.to_policy_values()
|
||||||
return _ENFORCER.enforce('context_is_admin', target, credentials)
|
return _ENFORCER.enforce('context_is_admin', target, credentials)
|
||||||
|
|||||||
Reference in New Issue
Block a user