pub struct RbacManager { /* private fields */ }Expand description
Role-Based Access Control manager
Implementations§
Source§impl RbacManager
impl RbacManager
pub fn new(config: RbacConfig) -> Self
Sourcepub fn check_permission(
&self,
user_id: &str,
permission: &str,
) -> PermissionCheck
pub fn check_permission( &self, user_id: &str, permission: &str, ) -> PermissionCheck
Check if user has specific permission
Sourcepub fn check_permissions(
&self,
user_id: &str,
permissions: &[&str],
) -> PermissionCheck
pub fn check_permissions( &self, user_id: &str, permissions: &[&str], ) -> PermissionCheck
Check multiple permissions (user must have ALL of them)
Sourcepub fn check_resource_access(
&self,
user_id: &str,
resource: &str,
action: &str,
) -> PermissionCheck
pub fn check_resource_access( &self, user_id: &str, resource: &str, action: &str, ) -> PermissionCheck
Check if user can access resource with specific action
Sourcepub fn remove_user_role(&mut self, user_id: &str) -> Result<()>
pub fn remove_user_role(&mut self, user_id: &str) -> Result<()>
Remove role from user
Sourcepub fn add_permission_to_role(
&mut self,
role: &str,
permission: &str,
) -> Result<()>
pub fn add_permission_to_role( &mut self, role: &str, permission: &str, ) -> Result<()>
Add permission to role
Sourcepub fn remove_permission_from_role(
&mut self,
role: &str,
permission: &str,
) -> Result<()>
pub fn remove_permission_from_role( &mut self, role: &str, permission: &str, ) -> Result<()>
Remove permission from role
Sourcepub fn create_role(
&mut self,
role: &str,
permissions: Vec<String>,
) -> Result<()>
pub fn create_role( &mut self, role: &str, permissions: Vec<String>, ) -> Result<()>
Create a new role
Sourcepub fn delete_role(&mut self, role: &str) -> Result<()>
pub fn delete_role(&mut self, role: &str) -> Result<()>
Delete a role
Sourcepub fn get_user_role(&self, user_id: &str) -> String
pub fn get_user_role(&self, user_id: &str) -> String
Get user’s role
Sourcepub fn get_user_permissions(&self, user_id: &str) -> Vec<String>
pub fn get_user_permissions(&self, user_id: &str) -> Vec<String>
Get user’s permissions
Sourcepub fn get_user_roles(&self) -> HashMap<String, String>
pub fn get_user_roles(&self) -> HashMap<String, String>
Get all users and their roles
Sourcepub fn remove_admin(&mut self, user_id: &str) -> Result<()>
pub fn remove_admin(&mut self, user_id: &str) -> Result<()>
Remove admin user
pub fn is_enabled(&self) -> bool
Auto Trait Implementations§
impl Freeze for RbacManager
impl RefUnwindSafe for RbacManager
impl Send for RbacManager
impl Sync for RbacManager
impl Unpin for RbacManager
impl UnwindSafe for RbacManager
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