pub struct AuthState { /* private fields */ }Expand description
A cloneable snapshot of the auth state shared between Database and every
mounted Table. Cloning is cheap (one Arc bump).
The require_auth flag is read live from the catalog on every check, so
enable_auth / offline-disable are reflected immediately. The principal
is the open-time cached value; daemons that need per-request principals
should swap in their own TableAuthChecker.
Implementations§
Source§impl AuthState
impl AuthState
Sourcepub fn new(require_auth: bool, principal: Option<Principal>) -> Self
pub fn new(require_auth: bool, principal: Option<Principal>) -> Self
Create a new auth state. require_auth is the initial catalog value;
principal is the cached principal (if any).
Sourcepub fn require_auth(&self) -> bool
pub fn require_auth(&self) -> bool
Whether enforcement is currently active.
Sourcepub fn set_require_auth(&self, value: bool)
pub fn set_require_auth(&self, value: bool)
Update the require_auth flag. Called by Database when the catalog
flag changes (e.g. enable_auth).
Sourcepub fn set_principal(&self, principal: Option<Principal>)
pub fn set_principal(&self, principal: Option<Principal>)
Replace the cached principal. Called by Database::open_with_credentials,
enable_auth, and refresh_principal.
Sourcepub fn require(&self, table_name: &str, perm: RequiredPermission) -> Result<()>
pub fn require(&self, table_name: &str, perm: RequiredPermission) -> Result<()>
Enforcement check: if require_auth is true, verify the cached
principal satisfies perm for table_name. On credentialless
databases, this is a no-op (Ok(())).
This is the primary entry point called by Table and Transaction
enforcement points.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for AuthState
impl !UnwindSafe for AuthState
impl Freeze for AuthState
impl Send for AuthState
impl Sync for AuthState
impl Unpin for AuthState
impl UnsafeUnpin for AuthState
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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