jwks
Fetch and parse JSON Web Key Set (JWKS)
cargo add jwks
Usage
From a jwks url.
let jwks_url = "https://www.googleapis.com/oauth2/v3/certs";
let jwks = from_jwks_url.await.unwrap;
From a openid config url.
let openid_config_url = "https://accounts.google.com/.well-known/openid-configuration";
let jwks = from_oidc_url.await.unwrap;
Use with jsonwebtokn to validate a jwt
use ;
let jwt = "...base64-encoded-jwt...";
// get the kid from jwt
let header = decode_header.expect;
let kid = header.kid.as_ref.expect;
// get a jwk from jwks by kid
let jwks_url = "https://www.googleapis.com/oauth2/v3/certs";
let jwks = from_jwks_url.await.unwrap;
let jwk = jwks.keys.get.expect;
let validation = default;
let decoded_token: = .expect;