pub enum AuthPolicy {
Public,
Authenticated,
Owner,
HasRole(Vec<String>),
ServiceOnly,
AdminOnly,
And(Vec<AuthPolicy>),
Or(Vec<AuthPolicy>),
Custom(fn(&AuthContext) -> bool),
}Expand description
Authorization policy for an operation
Variants§
Public
Public access (no auth required)
Authenticated
Any authenticated user
Owner
Owner of the resource only
HasRole(Vec<String>)
User must have one of these roles
ServiceOnly
Service-to-service only
AdminOnly
Admin only
And(Vec<AuthPolicy>)
Combination of policies (AND)
Or(Vec<AuthPolicy>)
Combination of policies (OR)
Custom(fn(&AuthContext) -> bool)
Custom policy function
Implementations§
Source§impl AuthPolicy
impl AuthPolicy
Sourcepub fn check(&self, context: &AuthContext) -> bool
pub fn check(&self, context: &AuthContext) -> bool
Check if auth context satisfies this policy
Sourcepub fn parse_policy(s: &str) -> Self
pub fn parse_policy(s: &str) -> Self
Parse policy from string (for YAML config)
Trait Implementations§
Source§impl Clone for AuthPolicy
impl Clone for AuthPolicy
Source§fn clone(&self) -> AuthPolicy
fn clone(&self) -> AuthPolicy
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AuthPolicy
impl RefUnwindSafe for AuthPolicy
impl Send for AuthPolicy
impl Sync for AuthPolicy
impl Unpin for AuthPolicy
impl UnwindSafe for AuthPolicy
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