pub struct JwksKeyStore { /* private fields */ }Expand description
A JWKS key store that fetches and caches public keys from a JWKS endpoint.
Keys are cached with a configurable TTL. When the cache expires, the next lookup triggers a refresh. If the endpoint is unavailable but the cache is warm, stale cached keys are used with a warning logged.
Implementations§
Source§impl JwksKeyStore
impl JwksKeyStore
Sourcepub fn new(url: &str, ttl: Duration) -> Self
pub fn new(url: &str, ttl: Duration) -> Self
Creates a new JwksKeyStore with the given endpoint URL and cache TTL.
Sourcepub async fn fetch(&self) -> Result<(), IdentityError>
pub async fn fetch(&self) -> Result<(), IdentityError>
Fetches the JWKS from the configured endpoint and updates the cache.
§Errors
Returns IdentityError::ProviderUnavailable if the endpoint cannot be reached.
Sourcepub async fn get_key(&self, kid: &str) -> Option<DecodingKey>
pub async fn get_key(&self, kid: &str) -> Option<DecodingKey>
Returns the DecodingKey for the given kid, fetching from the endpoint if
the cache is expired or empty.
Sourcepub async fn get_algorithm(&self, kid: &str) -> Option<String>
pub async fn get_algorithm(&self, kid: &str) -> Option<String>
Returns the algorithm string for the given kid, if cached.
Sourcepub async fn is_cache_valid(&self) -> bool
pub async fn is_cache_valid(&self) -> bool
Returns true if the cache has keys and is within TTL.
Auto Trait Implementations§
impl Freeze for JwksKeyStore
impl !RefUnwindSafe for JwksKeyStore
impl Send for JwksKeyStore
impl Sync for JwksKeyStore
impl Unpin for JwksKeyStore
impl UnsafeUnpin for JwksKeyStore
impl !UnwindSafe for JwksKeyStore
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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