pub struct InMemoryRbacProvider { /* private fields */ }Expand description
In-memory RBAC provider for testing and simple use cases
Implementations§
Source§impl InMemoryRbacProvider
impl InMemoryRbacProvider
Sourcepub fn add_permission(&mut self, permission: Permission)
pub fn add_permission(&mut self, permission: Permission)
Add a permission
Sourcepub fn assign_role_to_user_mut(
&mut self,
user_id: &str,
role_id: &str,
) -> AuthResult<()>
pub fn assign_role_to_user_mut( &mut self, user_id: &str, role_id: &str, ) -> AuthResult<()>
Assign a role to a user
Sourcepub fn remove_role_from_user_mut(
&mut self,
user_id: &str,
role_id: &str,
) -> AuthResult<()>
pub fn remove_role_from_user_mut( &mut self, user_id: &str, role_id: &str, ) -> AuthResult<()>
Remove a role from a user
Sourcepub fn get_users_with_role(&self, role_id: &str) -> Vec<String>
pub fn get_users_with_role(&self, role_id: &str) -> Vec<String>
Get all users with a specific role
Sourcepub fn get_role_stats(&self) -> HashMap<String, u32>
pub fn get_role_stats(&self) -> HashMap<String, u32>
Get role assignment statistics
Trait Implementations§
Source§impl Clone for InMemoryRbacProvider
impl Clone for InMemoryRbacProvider
Source§fn clone(&self) -> InMemoryRbacProvider
fn clone(&self) -> InMemoryRbacProvider
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for InMemoryRbacProvider
impl Debug for InMemoryRbacProvider
Source§impl Default for InMemoryRbacProvider
impl Default for InMemoryRbacProvider
Source§impl RbacProvider for InMemoryRbacProvider
impl RbacProvider for InMemoryRbacProvider
Source§fn get_role<'life0, 'life1, 'async_trait>(
&'life0 self,
role_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<Role>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_role<'life0, 'life1, 'async_trait>(
&'life0 self,
role_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<Role>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a role by ID
Source§fn get_permission<'life0, 'life1, 'async_trait>(
&'life0 self,
permission_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<Permission>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_permission<'life0, 'life1, 'async_trait>(
&'life0 self,
permission_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<Permission>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a permission by ID
Source§fn get_user_roles<'life0, 'life1, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<Vec<Role>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_user_roles<'life0, 'life1, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<Vec<Role>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get all roles for a user
Source§fn get_user_permissions<'life0, 'life1, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<Vec<Permission>>> + 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 = AuthResult<Vec<Permission>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get all permissions for a user (direct and through roles)
Source§fn assign_role_to_user<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_user_id: &'life1 str,
_role_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = AuthResult<()>> + 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_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = AuthResult<()>> + 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_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = AuthResult<()>> + 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_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = AuthResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Remove a role from a user
Source§fn user_has_role<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
role_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = AuthResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn user_has_role<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
role_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = AuthResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Check if a user has a specific role (including inherited roles)
Source§fn user_has_permission<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
resource: &'life2 str,
action: &'life3 str,
context: Option<&'life4 HashMap<String, Value>>,
) -> Pin<Box<dyn Future<Output = AuthResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn user_has_permission<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
resource: &'life2 str,
action: &'life3 str,
context: Option<&'life4 HashMap<String, Value>>,
) -> Pin<Box<dyn Future<Output = AuthResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Check if a user has a specific permission
Source§fn get_effective_user_roles<'life0, 'life1, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<Vec<Role>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_effective_user_roles<'life0, 'life1, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<Vec<Role>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get effective roles for a user (including inherited roles)
Auto Trait Implementations§
impl Freeze for InMemoryRbacProvider
impl RefUnwindSafe for InMemoryRbacProvider
impl Send for InMemoryRbacProvider
impl Sync for InMemoryRbacProvider
impl Unpin for InMemoryRbacProvider
impl UnsafeUnpin for InMemoryRbacProvider
impl UnwindSafe for InMemoryRbacProvider
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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