pub struct RbacManager { /* private fields */ }Expand description
RBAC manager for role and permission management.
Implementations§
Source§impl RbacManager
impl RbacManager
Sourcepub fn with_data_dir(data_dir: Option<PathBuf>) -> Self
pub fn with_data_dir(data_dir: Option<PathBuf>) -> Self
Create a new RBAC manager, loading state from disk if data_dir is provided.
Sourcepub fn create_role(
&self,
name: &str,
description: &str,
permissions: Vec<Permission>,
created_by: &str,
) -> Result<(), String>
pub fn create_role( &self, name: &str, description: &str, permissions: Vec<Permission>, created_by: &str, ) -> Result<(), String>
Create a new role.
Sourcepub fn list_roles(&self) -> Vec<Role>
pub fn list_roles(&self) -> Vec<Role>
List all roles.
Sourcepub fn assign_role(&self, user_id: &str, role_name: &str) -> Result<(), String>
pub fn assign_role(&self, user_id: &str, role_name: &str) -> Result<(), String>
Assign a role to a user.
Sourcepub fn revoke_role(&self, user_id: &str, role_name: &str) -> Result<(), String>
pub fn revoke_role(&self, user_id: &str, role_name: &str) -> Result<(), String>
Revoke a role from a user.
Sourcepub fn get_user_roles(&self, user_id: &str) -> Vec<String>
pub fn get_user_roles(&self, user_id: &str) -> Vec<String>
Get all roles for a user.
Sourcepub fn check_permission(&self, user_id: &str, permission: Permission) -> bool
pub fn check_permission(&self, user_id: &str, permission: Permission) -> bool
Check if a user has a specific permission.
Sourcepub fn get_user_permissions(&self, user_id: &str) -> HashSet<Permission>
pub fn get_user_permissions(&self, user_id: &str) -> HashSet<Permission>
Get all permissions for a user.
Sourcepub fn add_row_policy(&self, policy: RowLevelPolicy)
pub fn add_row_policy(&self, policy: RowLevelPolicy)
Add a row-level security policy.
Sourcepub fn get_row_policies(
&self,
table: &str,
user_id: &str,
) -> Vec<RowLevelPolicy>
pub fn get_row_policies( &self, table: &str, user_id: &str, ) -> Vec<RowLevelPolicy>
Get row-level policies for a table.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RbacManager
impl !RefUnwindSafe for RbacManager
impl Send for RbacManager
impl Sync for RbacManager
impl Unpin for RbacManager
impl UnsafeUnpin 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