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

#570 in Encoding

Download history 42899/week @ 2024-07-21 41122/week @ 2024-07-28 47466/week @ 2024-08-04 52427/week @ 2024-08-11 51720/week @ 2024-08-18 70100/week @ 2024-08-25 48520/week @ 2024-09-01 56608/week @ 2024-09-08 42961/week @ 2024-09-15 55105/week @ 2024-09-22 65734/week @ 2024-09-29 39532/week @ 2024-10-06 68343/week @ 2024-10-13 58074/week @ 2024-10-20 54266/week @ 2024-10-27 40842/week @ 2024-11-03

222,900 downloads per month
Used in 96 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
~111K SLoC