pub struct JwtCache { /* private fields */ }Expand description
A bounded cache of validated tokens.
Implementations§
Source§impl JwtCache
impl JwtCache
Sourcepub fn new(enabled: bool, max_lifetime_secs: u64) -> Option<Self>
pub fn new(enabled: bool, max_lifetime_secs: u64) -> Option<Self>
Build a cache, or None if the configuration turns it off.
A zero lifetime disables it, as in PostgREST – an entry that expires the moment it is written is only overhead.
Sourcepub fn authenticate(
&self,
auth_header: Option<&str>,
config: &JwtConfig,
) -> Result<AuthResult, JwtError>
pub fn authenticate( &self, auth_header: Option<&str>, config: &JwtConfig, ) -> Result<AuthResult, JwtError>
Authenticate, consulting the cache.
Falls through to crate::authenticate for anything not cacheable: a
request with no token at all, and a token already at or past its own
expiry.
Auto Trait Implementations§
impl !Freeze for JwtCache
impl RefUnwindSafe for JwtCache
impl Send for JwtCache
impl Sync for JwtCache
impl Unpin for JwtCache
impl UnsafeUnpin for JwtCache
impl UnwindSafe for JwtCache
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