Skip to content
/ rust-jwt Public

Very simple JWT generation lib

License

Notifications You must be signed in to change notification settings

durch/rust-jwt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MIT licensed

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);
}

Releases

No releases published

Packages

No packages published

Languages