pub struct AuthorizationService<R, G>{ /* private fields */ }Expand description
Domain service for authorization decisions.
This service contains pure business logic for determining whether an account is authorized based on an access policy. It has no external dependencies and can be used across different application contexts.
Implementations§
Source§impl<R, G> AuthorizationService<R, G>
impl<R, G> AuthorizationService<R, G>
Sourcepub fn new(policy: AccessPolicy<R, G>) -> Self
pub fn new(policy: AccessPolicy<R, G>) -> Self
Creates a new authorization service with the given access policy.
Determines if the account is authorized based on any of the configured criteria.
Returns true if the account matches ANY of:
- Required permissions
- Required groups
- Required exact roles
- Required roles via supervisor relationship (ordering: higher privilege > lower privilege)
Sourcepub fn meets_role_requirement(&self, account: &Account<R, G>) -> bool
pub fn meets_role_requirement(&self, account: &Account<R, G>) -> bool
Checks if the account meets any of the required roles.
Sourcepub fn meets_role_hierarchy_requirement(&self, account: &Account<R, G>) -> bool
pub fn meets_role_hierarchy_requirement(&self, account: &Account<R, G>) -> bool
Checks if the account has a role that satisfies a required role via hierarchy ordering.
Ordering contract: Higher privilege > Lower privilege. A supervisor or the same role satisfies: user_role >= required_role.
Sourcepub fn meets_group_requirement(&self, account: &Account<R, G>) -> bool
pub fn meets_group_requirement(&self, account: &Account<R, G>) -> bool
Checks if the account meets any of the required groups.
Sourcepub fn meets_permission_requirement(&self, account: &Account<R, G>) -> bool
pub fn meets_permission_requirement(&self, account: &Account<R, G>) -> bool
Checks if the account meets any of the required permissions.
Sourcepub fn policy_denies_all_access(&self) -> bool
pub fn policy_denies_all_access(&self) -> bool
Returns true if the policy denies all access (no requirements configured).
Trait Implementations§
Source§impl<R, G> Clone for AuthorizationService<R, G>
impl<R, G> Clone for AuthorizationService<R, G>
Source§fn clone(&self) -> AuthorizationService<R, G>
fn clone(&self) -> AuthorizationService<R, G>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<R, G> Freeze for AuthorizationService<R, G>
impl<R, G> RefUnwindSafe for AuthorizationService<R, G>where
G: RefUnwindSafe,
R: RefUnwindSafe,
impl<R, G> Send for AuthorizationService<R, G>
impl<R, G> Sync for AuthorizationService<R, G>
impl<R, G> Unpin for AuthorizationService<R, G>
impl<R, G> UnsafeUnpin for AuthorizationService<R, G>
impl<R, G> UnwindSafe for AuthorizationService<R, G>where
G: UnwindSafe,
R: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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>
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>
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