pub trait JwtKeySource:
Send
+ Sync
+ 'static {
// Required methods
fn get_key<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
issuer: &'life1 str,
kid: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<VerifyingKey>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn is_trusted(&self, issuer: &str) -> bool;
fn local_issuers(&self) -> &[String];
// Provided methods
fn get_keys<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
issuer: &'life1 str,
kid: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<VerifyingKey>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn ml_dsa_verifying_keys(&self) -> Vec<MlDsaVerifyingKey> ⓘ { ... }
fn composite_key_set(&self) -> Arc<CompositeKeySet> ⓘ { ... }
fn composite_pair(&self, kid: &str) -> Option<CompositeKeyPair> { ... }
fn kid_algs(&self, _issuer: &str, _kid: &str) -> Vec<String> { ... }
}Expand description
Source of JWT verification keys.
Abstracts key resolution for both local (cluster CA) and federated (external IdP) tokens. Services receive this at construction time, binding them to their trust anchors.
Required Methods§
Sourcefn get_key<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
issuer: &'life1 str,
kid: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<VerifyingKey>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_key<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
issuer: &'life1 str,
kid: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<VerifyingKey>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Get the verifying key for a given issuer and optional kid.
A supplied kid is a strict selector: implementations MUST return only
the key published under that exact name or fail. It is never permission
to substitute another co-published key. Kid-less multi-key verification
uses JwtKeySource::get_keys instead.
§Errors
Returns error if the issuer is untrusted or key resolution fails.
Sourcefn is_trusted(&self, issuer: &str) -> bool
fn is_trusted(&self, issuer: &str) -> bool
Check if an issuer is trusted (before attempting key fetch).
Returns true for local issuers and configured federated issuers.
Sourcefn local_issuers(&self) -> &[String]
fn local_issuers(&self) -> &[String]
List of issuer URLs considered “local” (for subject formatting).
Used by Claims::subject() to determine whether to namespace the
subject with the issuer URL (federated) or use it bare (local).
Provided Methods§
Sourcefn get_keys<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
issuer: &'life1 str,
kid: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<VerifyingKey>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_keys<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
issuer: &'life1 str,
kid: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<VerifyingKey>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Resolve all algorithm-compatible candidates for an issuer/kid pair.
This is the safe default for verifying a kid-less JWT: when no kid
selector is present the verifier cannot know which published key signed
the token, so it MUST retain every compatible candidate and try each
until one verifies — never collapse the published set to a positional
singleton (first/next/values().next()). See #1183 / #1184.
Single-key sources return a one-element vec. JWKS-backed sources
override this to return every Ed25519 entry when kid is None.
Callers pair this with crate::auth::jwt::decode_with_any_key to
try each candidate against the JWT signature.
Sourcefn ml_dsa_verifying_keys(&self) -> Vec<MlDsaVerifyingKey> ⓘ
fn ml_dsa_verifying_keys(&self) -> Vec<MlDsaVerifyingKey> ⓘ
Get all current ML-DSA-65 verifying keys for PQ-hybrid JWT verification.
Returns keys for all rotation slots (drain/active/lead) so that tokens signed by any current slot can be verified. Empty vec disables PQ verification.
Sourcefn composite_key_set(&self) -> Arc<CompositeKeySet> ⓘ
fn composite_key_set(&self) -> Arc<CompositeKeySet> ⓘ
Return the authoritative exact-pair composite key ledger.
Sourcefn composite_pair(&self, kid: &str) -> Option<CompositeKeyPair>
fn composite_pair(&self, kid: &str) -> Option<CompositeKeyPair>
Resolve the exact composite verification pair for a JOSE kid.
The default consults the composite key ledger. Sources that also hold
an out-of-ledger CA composite pair (the service-JWT plane, where the
ML-DSA-65 half is derived from the CA JWT signing key rather than
rotated through the ledger) override this to consult it as well.
An unknown kid resolves to None — verification fails closed.
Sourcefn kid_algs(&self, _issuer: &str, _kid: &str) -> Vec<String>
fn kid_algs(&self, _issuer: &str, _kid: &str) -> Vec<String>
Return the list of alg values bound to a given kid in the JWKS.
This is used as a stripping defense: when a JWKS entry carries a
composite-signature alg (e.g. ML-DSA-65-Ed25519) under a kid, the
verifier MUST require that any JWT presenting that kid uses the exact
same alg — preventing an attacker who controls one component key from
presenting a single-algorithm JWT under the composite kid.
Default implementation returns an empty vec, which means “no policy constraint” (legacy behavior). Implementations backed by JWKS should override to surface the algs they observed.