Crate simple_jwt [−] [src]
Introduction
A very simple crate to deal with json web token,
this lib use the rust-openssl
, so you may want to check the
rust-openssl to find the
set-up of openssl runtime lib.
Support Algirithm
- HS256/384/512
- RS256/384/512
- to be added...
Example
use simple_jwt::{encode, decode, Claim, Algorithm}; let mut claim = Claim::default(); claim.set_iss("some iss"); claim.set_payload_field("stringhh", 12); let result = encode(&claim, "secret", Algorithm::HS256).unwrap(); println!("hashed result is {}", result); let new_claim = decode(&result, "secret").unwrap(); assert_eq!(claim, new_claim);Run
The test in lib.rs contains more example
Structs
Claim | |
Header |
Enums
Algorithm | |
JWTError |
all the errors may raised during jwt encode/decode |
Traits
JWTStringConvertable |
trait that can be convert to/from base64 string impl for serde::Serialize+serde::Deserialize are already defined |
Functions
decode |
decode a jwt string using algorithm in the jwt header field |
encode |
encode a Claim to jwt string, if you are using RS256/384/512, secret should be your private key |
Type Definitions
Result |