pub struct RbacContext { /* private fields */ }Available on crate feature
rbac only.Expand description
Helper class for manipulation of RBAC tables
Implementationsยง
Sourceยงimpl RbacContext
impl RbacContext
Sourcepub fn load<C: TransactionTrait>(db: &C) -> Result<Self, DbErr>
pub fn load<C: TransactionTrait>(db: &C) -> Result<Self, DbErr>
Load context from database connection
Sourcepub fn add_tables<C: TransactionTrait>(
&mut self,
db: &C,
tables: &[&'static str],
) -> Result<(), DbErr>
pub fn add_tables<C: TransactionTrait>( &mut self, db: &C, tables: &[&'static str], ) -> Result<(), DbErr>
Add multiple tables as resources
Sourcepub fn add_crud_permissions<C: TransactionTrait>(
&mut self,
db: &C,
) -> Result<(), DbErr>
pub fn add_crud_permissions<C: TransactionTrait>( &mut self, db: &C, ) -> Result<(), DbErr>
Add CRUD actions
Sourcepub fn add_roles<C: TransactionTrait>(
&mut self,
db: &C,
roles: &[&'static str],
) -> Result<(), DbErr>
pub fn add_roles<C: TransactionTrait>( &mut self, db: &C, roles: &[&'static str], ) -> Result<(), DbErr>
Add multiple roles
pub fn get_role(&self, role: &'static str) -> Result<&RoleId, DbErr>
Sourcepub fn add_role_permissions<C: TransactionTrait>(
&mut self,
db: &C,
role: &'static str,
actions: &[&'static str],
tables: &[&'static str],
) -> Result<(), DbErr>
pub fn add_role_permissions<C: TransactionTrait>( &mut self, db: &C, role: &'static str, actions: &[&'static str], tables: &[&'static str], ) -> Result<(), DbErr>
Add permissions to roles. Will take cartesian product of tables and actions.
Sourcepub fn remove_role_permissions<C: TransactionTrait>(
&mut self,
db: &C,
role: &'static str,
actions: &[&'static str],
tables: &[&'static str],
) -> Result<(), DbErr>
pub fn remove_role_permissions<C: TransactionTrait>( &mut self, db: &C, role: &'static str, actions: &[&'static str], tables: &[&'static str], ) -> Result<(), DbErr>
Remove permissions from roles. Will take cartesian product of tables and actions.
pub fn add_user_override<C: TransactionTrait>( &mut self, db: &C, rows: &[RbacAddUserOverride], ) -> Result<(), DbErr>
pub fn add_role_hierarchy<C: TransactionTrait>( &mut self, db: &C, rows: &[RbacAddRoleHierarchy], ) -> Result<(), DbErr>
Sourcepub fn assign_user_role<C: TransactionTrait>(
&mut self,
db: &C,
rows: &[(i64, &'static str)],
) -> Result<(), DbErr>
pub fn assign_user_role<C: TransactionTrait>( &mut self, db: &C, rows: &[(i64, &'static str)], ) -> Result<(), DbErr>
Assign role to users. Note that each user can only have 1 role,
so this assignment replaces current role.
rows: (UserId, role)
Trait Implementationsยง
Auto Trait Implementationsยง
impl Freeze for RbacContext
impl RefUnwindSafe for RbacContext
impl Send for RbacContext
impl Sync for RbacContext
impl Unpin for RbacContext
impl UnwindSafe for RbacContext
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