pub struct JwksCache { /* private fields */ }Expand description
Caches JWKS keys fetched from the OIDC provider.
Keys are refreshed after JWKS_CACHE_TTL or on cache miss for a specific kid.
Implementations§
Source§impl JwksCache
impl JwksCache
pub fn new(issuer: String) -> Self
Sourcepub fn with_jwks(issuer: String, jwks: JwkSet) -> Self
pub fn with_jwks(issuer: String, jwks: JwkSet) -> Self
For testing: create a cache pre-loaded with keys (no HTTP fetching needed).
Sourcepub async fn get_jwks(&self) -> Result<JwkSet>
pub async fn get_jwks(&self) -> Result<JwkSet>
Get the JWKS, fetching from the provider if the cache is stale or empty.
Sourcepub async fn refresh(&self) -> Result<JwkSet>
pub async fn refresh(&self) -> Result<JwkSet>
Force-refresh the JWKS (e.g., when a kid is not found in the current set).
Sourcepub async fn find_key(&self, kid: &str) -> Result<DecodingKey>
pub async fn find_key(&self, kid: &str) -> Result<DecodingKey>
Find a decoding key by kid (key ID) from the cached JWKS.
If the kid isn’t found, refreshes the cache once and retries.
Sourcepub async fn find_any_key(&self, alg: Algorithm) -> Result<DecodingKey>
pub async fn find_any_key(&self, alg: Algorithm) -> Result<DecodingKey>
Find a decoding key when no kid is provided (use the first matching key).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for JwksCache
impl !RefUnwindSafe for JwksCache
impl Send for JwksCache
impl Sync for JwksCache
impl Unpin for JwksCache
impl UnsafeUnpin for JwksCache
impl !UnwindSafe for JwksCache
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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