pub struct AuthnCache { /* private fields */ }Expand description
Provider-local cache of successful authentication results.
Backed by std::sync::RwLock<HashMap> with lazy eviction, mirroring
[CachingPermissionEvaluator]. Entries never outlive their token: the
effective lifetime is min(configured TTL, token_exp - now), and hits
re-check now < expires_at.
Implementations§
Source§impl AuthnCache
impl AuthnCache
pub fn new(options: AuthnCacheOptions) -> Self
Sourcepub fn get(&self, key: &AuthnCacheKey) -> Option<AuthenticatedPrincipal>
pub fn get(&self, key: &AuthnCacheKey) -> Option<AuthenticatedPrincipal>
Look up a cached authentication result.
Returns None on miss OR when the entry’s token has expired (hits
re-check now < expires_at).
Sourcepub fn insert(
&self,
key: AuthnCacheKey,
principal: AuthenticatedPrincipal,
) -> bool
pub fn insert( &self, key: AuthnCacheKey, principal: AuthenticatedPrincipal, ) -> bool
Insert a minted principal, returning false when it is not stored.
The effective lifetime is min(configured TTL, token_exp - now); a
token whose exp has already passed (≤ 0 remaining) is NOT stored.
Tokens without an exp claim (e.g. static native tokens) use the
configured TTL.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for AuthnCache
impl RefUnwindSafe for AuthnCache
impl Send for AuthnCache
impl Sync for AuthnCache
impl Unpin for AuthnCache
impl UnsafeUnpin for AuthnCache
impl UnwindSafe for AuthnCache
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