JWKS-Client is a library written in Rust to decode and validate JWT tokens using a JSON Web Key Store.
Features
- Download key set from HTTP address
- Decode JWT tokens into header, payload and signature
- Verify token signature, expiry and not-before
- Can transfer payload in user-defined struct
- Consise results (see error::Type for example)
- Designed for a production system (not an academic project)
- Build with Rust stable
I created this library specifically to decode GCP/Firebase JWT but should be useable with little to no modification. Contact me to propose support for different JWKS key store. Feedback, suggestions, complaints and critisism is appreaciate.
Basic Usage
The following demonstrates how to load a set of keys from an HTTP address and verify a JWT token using those keys:
use KeyStore;
let jkws_url = "https://...";
let key_set = new_from.unwrap;
// ...
let token = "...";
match key_set.verify
JWKS-Client offers descriptive error results:
use KeyStore;
use ;
let jwks_url = "http://...";
let token = "...";
let key_set = new_from.unwrap;
match key_set.verify
JWKS-Client can decode a JWT payload into a struct:
use KeyStore;
let key_set = new;
let token = TOKEN;
let jwt = key_set.decode.unwrap;
if jwt.expired.unwrap_or else
TODO:
- More documentation :P
- Extract expiration time of keys from HTTP request
- Automatically refresh keys in background
(Made with ❤️ with Rust)