Basic Rust library to manipulate JWTs https://crates.io/crates/basic-jwt
Go to file
Pierre HUBERT e9eabede0d
All checks were successful
continuous-integration/drone/push Build is passing
Update Rust crate serde to v1.0.210
2024-09-12 00:36:31 +00:00
src Refactor API 2024-04-20 13:48:00 +02:00
.drone.yml Add Drone configuration 2024-04-20 13:21:05 +02:00
.gitignore Initial commit 2024-04-20 13:04:45 +02:00
Cargo.lock Update Rust crate serde to v1.0.210 2024-09-12 00:36:31 +00:00
Cargo.toml Update Rust crate serde to 1.0.200 2024-05-02 00:02:55 +00:00
README.md Refactor API 2024-04-20 13:48:00 +02:00
renovate.json Add Renovate configuration 2024-04-20 13:24:36 +02:00

Basic JWT

This crate provide basic functions to:

  • Sign JWT
  • Parse and validate JWT

Basic usage:

let claims = ...; // note : claims must be serializable

// Generate a key pair. Private and public key are both serializable
let priv_key = JWTPrivateKey::generate_ec384_signing_key().unwrap();
let pub_key = priv_key.to_public_key().unwrap();

// Create a JWT for the given claims (note: standard claims: sub, iss, ...) are not
// automatically added if they are missing
let jwt = priv_key.sign_jwt(&claims).expect("Failed to sign JWT!");

// Validate signed JWT
let claims_out = pub_key
            .validate_jwt::<Claims>(&jwt)
            .expect("Failed to validate JWT!");