pub struct AuthState {
pub config: Arc<ArcSwap<AppConfig>>,
pub cache: JwtCache,
}Expand description
Shared authentication state passed to the middleware via axum State.
Contains the config and JWT cache. Cloned per-request (cheap — all
fields are Arc or Clone-cheap).
The config field is an ArcSwap so that live config reloads
(triggered via NOTIFY dbrst, 'reload config') are visible to the
auth middleware without restarting the server.
Fields§
§config: Arc<ArcSwap<AppConfig>>§cache: JwtCacheImplementations§
Source§impl AuthState
impl AuthState
Sourcepub fn new(config: Arc<AppConfig>) -> Self
pub fn new(config: Arc<AppConfig>) -> Self
Create a new AuthState wrapping the given config snapshot.
The config is placed inside a fresh ArcSwap. Use
with_shared_config to share the
same ArcSwap with AppState for live-reload support.
Create an AuthState that shares an existing ArcSwap<AppConfig>.
When the ArcSwap is updated (e.g. during config reload), the
auth middleware automatically sees the new values.
Sourcepub fn load_config(&self) -> Guard<Arc<AppConfig>>
pub fn load_config(&self) -> Guard<Arc<AppConfig>>
Get a snapshot of the current config.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AuthState
impl !RefUnwindSafe for AuthState
impl Send for AuthState
impl Sync for AuthState
impl Unpin for AuthState
impl UnsafeUnpin for AuthState
impl !UnwindSafe 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
Mutably borrows from an owned value. Read more