Skip to main content

decode_with_key

Function decode_with_key 

Source
pub fn decode_with_key(
    token: &str,
    verifying_key: &VerifyingKey,
    expected_aud: Option<&str>,
) -> Result<Claims, JwtError>
Expand description

Decode a JWT using a caller-supplied verifying key (for multi-issuer support).

Uses lenient audience validation: if expected_aud is Some, a wrong aud is rejected but an absent aud is accepted. This allows federated tokens from issuers that don’t set aud while still rejecting cross-node replay attacks from issuers that do.