12 releases (7 breaking)

0.8.0 Oct 17, 2023
0.7.1 May 22, 2022
0.7.0 Apr 21, 2022
0.6.1 Feb 24, 2021
0.1.1 Dec 25, 2016

#110 in Authentication

Download history 55781/week @ 2023-12-11 61456/week @ 2023-12-18 10265/week @ 2023-12-25 34643/week @ 2024-01-01 41633/week @ 2024-01-08 36206/week @ 2024-01-15 51405/week @ 2024-01-22 43339/week @ 2024-01-29 49867/week @ 2024-02-05 47606/week @ 2024-02-12 31299/week @ 2024-02-19 56450/week @ 2024-02-26 38705/week @ 2024-03-04 52518/week @ 2024-03-11 50434/week @ 2024-03-18 59906/week @ 2024-03-25

202,763 downloads per month
Used in 94 crates (12 directly)

MIT license

9KB
165 lines

Build Status MIT licensed Join the chat at https://gitter.im/durch/rust-jwt

rust-jwt [docs]

Very simple JWT generation lib, provides a Jwt struct which can be finalised to produce an encoded and signed String representation.

Generic over serde::ser::Serialize trait.

Usage

#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate smpl_jwt;

use serde::Serialize;
use smpl_jwt::{Jwt, RSAKey};

fn main() {
  #[derive(Serialize)]
  struct ExampleStruct {
    field: String
  }

  let rsa_key = match RSAKey::from_pem("random_rsa_for_testing") {
    Ok(x) => x,
    Err(e) => panic!("{}", e)
  };

  let jwt = Jwt::new(ExampleStruct{field: String::from("test")},
                    rsa_key,
                    None);
  println!("{}", jwt);
}

Dependencies

~3–5MB
~105K SLoC