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

#977 in Encoding

Download history 57141/week @ 2024-11-21 61569/week @ 2024-11-28 73273/week @ 2024-12-05 65876/week @ 2024-12-12 18727/week @ 2024-12-19 7851/week @ 2024-12-26 41861/week @ 2025-01-02 59419/week @ 2025-01-09 49974/week @ 2025-01-16 37776/week @ 2025-01-23 47870/week @ 2025-01-30 64711/week @ 2025-02-06 42360/week @ 2025-02-13 55448/week @ 2025-02-20 60276/week @ 2025-02-27 59964/week @ 2025-03-06

230,878 downloads per month
Used in 101 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