validate_and_cache_token

Function validate_and_cache_token 

Source
pub async fn validate_and_cache_token<T>(
    cache: &Arc<dyn JwksCache>,
    token: &str,
    jwks_uri: &str,
    config: &(impl AuthenticationConfigProvider + Send + Sync),
) -> Result<T, OidcError>
where T: DeserializeOwned + Serialize + Clone + Send + Sync + 'static,
Expand description

Validates a JWT token and caches the validation result.

This is the main validation orchestration function that:

  1. Checks if the token’s claims are already cached
  2. If not cached, extracts the key ID from the token header
  3. Retrieves the appropriate JWK (from cache or by fetching JWKS)
  4. Validates the token and caches the result

§Arguments

  • cache - The cache implementation to use
  • token - The JWT token to validate
  • jwks_uri - The URI where JWKs can be fetched
  • config - Configuration provider for cache TTL settings

§Returns

The validated and deserialized token claims