pub struct PolicySet { /* private fields */ }
Expand description
A set of policies being evaluated to determine the permissions in effect.
Implementations§
Source§impl PolicySet
impl PolicySet
Sourcepub fn add_policy(&mut self, source: PolicySource, policy: Policy)
pub fn add_policy(&mut self, source: PolicySource, policy: Policy)
Add a policy to the set from the given source.
§Example
let policy = Policy::from_str(r#"{"Statement": {"Effect": "Allow", "Action": "*", "Resource": "*"}}"#).unwrap();
let source = PolicySource::new_entity_inline("arn:aws:iam::123456789012:user/username", "AIDAEXAMPLEUSERID00", "PolicyName");
let mut policy_set = PolicySet::new();
policy_set.add_policy(source, policy);
assert_eq!(policy_set.policies().len(), 1);
Sourcepub fn policies(&self) -> &Vec<(PolicySource, Policy)>
pub fn policies(&self) -> &Vec<(PolicySource, Policy)>
Return the policies in the policy set.
Sourcepub fn evaluate<'a>(
&'a self,
context: &Context,
) -> Result<(Decision, Vec<&'a PolicySource>), AspenError>
pub fn evaluate<'a>( &'a self, context: &Context, ) -> Result<(Decision, Vec<&'a PolicySource>), AspenError>
Evaluate the policy set. If a denial is found, return a Deny and the source immediately. Otherwise, if one or more approvals are found, return Allow and the relevant sources. Otherwise, return a DefaultDeny with no sources.
Sourcepub fn evaluate_all<'a>(
&'a self,
context: &Context,
) -> Result<(Decision, Vec<&'a PolicySource>), AspenError>
pub fn evaluate_all<'a>( &'a self, context: &Context, ) -> Result<(Decision, Vec<&'a PolicySource>), AspenError>
Evaluate all policies in the policy set. If one or more denials are found, return a Deny and the relevant sources. Otherwise, if one or more approvals are found, return Allow and the relevant sources. Otherwise, return a DefaultDeny with no sources.
Trait Implementations§
impl Eq for PolicySet
impl StructuralPartialEq for PolicySet
Auto Trait Implementations§
impl Freeze for PolicySet
impl RefUnwindSafe for PolicySet
impl Send for PolicySet
impl Sync for PolicySet
impl Unpin for PolicySet
impl UnwindSafe for PolicySet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more