pub struct AuthorizationController { /* private fields */ }Expand description
Role-based authorization controller.
Checks permissions for authenticated entities based on their roles and the authorization context.
Implementations§
Source§impl AuthorizationController
impl AuthorizationController
Sourcepub fn new(policy: AuthorizationPolicy) -> Self
pub fn new(policy: AuthorizationPolicy) -> Self
Create a controller with a custom policy.
Sourcepub fn with_default_policy() -> Self
pub fn with_default_policy() -> Self
Create a controller with the default Peat Protocol policy.
Sourcepub fn check_permission(
&self,
entity: &AuthenticatedEntity,
permission: Permission,
context: &AuthorizationContext,
) -> Result<(), SecurityError>
pub fn check_permission( &self, entity: &AuthenticatedEntity, permission: Permission, context: &AuthorizationContext, ) -> Result<(), SecurityError>
Check if an entity has a permission in the given context.
Returns Ok(()) if the permission is granted, or an error if denied.
Sourcepub fn get_roles(
&self,
entity: &AuthenticatedEntity,
context: &AuthorizationContext,
) -> HashSet<Role>
pub fn get_roles( &self, entity: &AuthenticatedEntity, context: &AuthorizationContext, ) -> HashSet<Role>
Get the roles for an entity in the given context.
Sourcepub fn policy(&self) -> &AuthorizationPolicy
pub fn policy(&self) -> &AuthorizationPolicy
Get the underlying policy.
Trait Implementations§
Source§impl Debug for AuthorizationController
impl Debug for AuthorizationController
Auto Trait Implementations§
impl Freeze for AuthorizationController
impl RefUnwindSafe for AuthorizationController
impl Send for AuthorizationController
impl Sync for AuthorizationController
impl Unpin for AuthorizationController
impl UnsafeUnpin for AuthorizationController
impl UnwindSafe for AuthorizationController
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more