pub struct AuthorizationService { /* private fields */ }Expand description
Default authorization service with in-memory storage
Implementations§
Source§impl AuthorizationService
impl AuthorizationService
Sourcepub fn with_cache(cache: Arc<dyn PermissionCacheBackend>) -> Self
pub fn with_cache(cache: Arc<dyn PermissionCacheBackend>) -> Self
Create a new authorization service with a custom cache backend
Sourcepub fn with_config(
config: AuthorizationConfig,
cache: Arc<dyn PermissionCacheBackend>,
) -> Self
pub fn with_config( config: AuthorizationConfig, cache: Arc<dyn PermissionCacheBackend>, ) -> Self
Create a new authorization service with custom config and cache backend
Sourcepub async fn clear_user_cache(&self, user_id: &str)
pub async fn clear_user_cache(&self, user_id: &str)
Clear permission cache for a user
Sourcepub async fn clear_all_cache(&self)
pub async fn clear_all_cache(&self)
Clear all permission caches
Trait Implementations§
Source§impl AuthorizationServiceTrait for AuthorizationService
impl AuthorizationServiceTrait for AuthorizationService
Check if a user is authorized to perform an action on a resource
Source§fn grant_permission_to_role<'life0, 'life1, 'async_trait>(
&'life0 self,
role: &'life1 str,
permission: Permission,
) -> Pin<Box<dyn Future<Output = Result<(), AuthorizationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn grant_permission_to_role<'life0, 'life1, 'async_trait>(
&'life0 self,
role: &'life1 str,
permission: Permission,
) -> Pin<Box<dyn Future<Output = Result<(), AuthorizationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Grant a permission to a role
Source§fn revoke_permission_from_role<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
role: &'life1 str,
permission: &'life2 Permission,
) -> Pin<Box<dyn Future<Output = Result<(), AuthorizationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn revoke_permission_from_role<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
role: &'life1 str,
permission: &'life2 Permission,
) -> Pin<Box<dyn Future<Output = Result<(), AuthorizationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Revoke a permission from a role
Source§fn assign_role_to_user<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
role: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), AuthorizationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn assign_role_to_user<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
role: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), AuthorizationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Assign a role to a user
Source§fn remove_role_from_user<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
role: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), AuthorizationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn remove_role_from_user<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
role: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), AuthorizationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Remove a role from a user
Source§fn get_user_permissions<'life0, 'life1, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Permission>, AuthorizationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_user_permissions<'life0, 'life1, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Permission>, AuthorizationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get all permissions for a user
Source§fn user_has_permission<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
permission: &'life2 Permission,
) -> Pin<Box<dyn Future<Output = Result<bool, AuthorizationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn user_has_permission<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
permission: &'life2 Permission,
) -> Pin<Box<dyn Future<Output = Result<bool, AuthorizationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Check if user has a specific permission
Auto Trait Implementations§
impl !RefUnwindSafe for AuthorizationService
impl !UnwindSafe for AuthorizationService
impl Freeze for AuthorizationService
impl Send for AuthorizationService
impl Sync for AuthorizationService
impl Unpin for AuthorizationService
impl UnsafeUnpin for AuthorizationService
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