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

#19 in #representation

Download history 40626/week @ 2024-06-17 48933/week @ 2024-06-24 37858/week @ 2024-07-01 48795/week @ 2024-07-08 38777/week @ 2024-07-15 42384/week @ 2024-07-22 41116/week @ 2024-07-29 47691/week @ 2024-08-05 52049/week @ 2024-08-12 52305/week @ 2024-08-19 69594/week @ 2024-08-26 49072/week @ 2024-09-02 56224/week @ 2024-09-09 42655/week @ 2024-09-16 56010/week @ 2024-09-23 65756/week @ 2024-09-30

221,975 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
~107K SLoC