pub struct Rbac { /* private fields */ }Expand description
Registers the Permissions store into application state.
Adds no routes. There is no first-party admin UI, deliberately: a screen that hands out permissions is an application’s own decision — about who may open it above all — and shipping one that is enabled by adding a plugin would be shipping a privilege-escalation route with an on switch.
Implementations§
Source§impl Rbac
impl Rbac
Sourcepub fn new(db: Database) -> Self
pub fn new(db: Database) -> Self
The defaults: the conventional tables, super-admin, a 30-second cache.
Sourcepub fn from_config(db: Database, config: &Config) -> Result<Self>
pub fn from_config(db: Database, config: &Config) -> Result<Self>
Read rbac.super_role (or rbac.super_roles) and rbac.cache_ttl_ms.
In .env that is RBAC_SUPER_ROLE=owner and RBAC_CACHE_TTL_MS=5000,
through whatever mapping the application’s configuration uses.
Sourcepub fn with_store(store: Permissions) -> Self
pub fn with_store(store: Permissions) -> Self
Use a store you built yourself — with different tables, say.
pub fn super_role(self, name: impl Into<String>) -> Self
pub fn cache_ttl(self, ttl: Duration) -> Self
Sourcepub fn store(&self) -> &Permissions
pub fn store(&self) -> &Permissions
The store, for wiring it into anything else that needs one.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Rbac
impl !UnwindSafe for Rbac
impl Freeze for Rbac
impl Send for Rbac
impl Sync for Rbac
impl Unpin for Rbac
impl UnsafeUnpin for Rbac
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