pub struct JwksCache { /* private fields */ }Expand description
Refresh-on-demand JWKS cache. Constructed by
super::JwtVerifier::from_jwks_url and consumed via
Self::snapshot on every verify.
Implementations§
Source§impl JwksCache
impl JwksCache
Sourcepub fn with_clock(self, clock: Arc<dyn Clock>) -> JwksCache
pub fn with_clock(self, clock: Arc<dyn Clock>) -> JwksCache
Swap the clock used for TTL calculation.
Defaults to WallClock. Tests inject a frozen clock to control
the stale-check without sleeping.
Source§impl JwksCache
impl JwksCache
Sourcepub async fn fetch(url: impl Into<String>) -> Result<JwksCache, VerifyError>
pub async fn fetch(url: impl Into<String>) -> Result<JwksCache, VerifyError>
Initial fetch + cache. Returns
VerifyError::KeysetUnavailable if the first fetch fails or
the response is not a parseable JWKS — the caller cannot
proceed without at least one usable keyset, by design.
Sourcepub fn for_test_empty() -> JwksCache
pub fn for_test_empty() -> JwksCache
Test-support ctor — bypasses JWKS fetch entirely. The cache
holds an empty keyset so any engine verify path rejects on
KidUnknown.
Sourcepub fn for_test_with_keys(keyset: KeySet) -> JwksCache
pub fn for_test_with_keys(keyset: KeySet) -> JwksCache
Test-support ctor holding a caller-supplied keyset, so a full
signature-passing verify can be exercised without a live JWKS
fetch (this crate deliberately avoids wiremock for boundary
checks). Pair with SigningKey::test_pair() to reach engine checks
that run after signature verification — the sv epoch gate, in
particular.