honest_jwt

Crates.iohonest_jwt
lib.rshonest_jwt
version0.1.0
sourcesrc
created_at2018-11-22 18:56:16.724267
updated_at2018-11-22 18:56:16.724267
descriptionJWT Implementation in Rust. Fork of frank_jwt.
homepagehttps://github.com/koala-kalda/honest_jwt
repositoryhttps://github.com/koala-kalda/honest_jwt
max_upload_size
id98189
size62,934
Koala Kalda (koala-kalda)

documentation

https://github.com/koala-kalda/honest_jwt

README

Honest JWT Library

Implementation of JSON Web Tokens in Rust. Honest about its feature set and actively maintained. Support for all claim checks and JWEs is a goal. Fork of frank_jwt.

Algorithms and features supported

  • HS256
  • HS384
  • HS512
  • RS256
  • RS384
  • RS512
  • ES256
  • ES384
  • ES512
  • Sign
  • Verify
  • iss check (issuer)
  • sub check (subject)
  • aud check (audience)
  • exp check (expiration time)
  • nbf check (not before time)
  • iat check (issued at)
  • jti check (JWT id)

Usage

Put this into your Cargo.toml:

[dependencies]
honest_jwt = "0.1"

And this in your crate root:

extern crate honest_jwt;
extern crate  #[macro_use] serde_json;

use honest_jwt::{Algorithm, encode, decode};

Example

//HS256
let mut payload = json!({
    "key1" : "val1",
    "key2" : "val2"
});
let mut header = json!({});
let secret = "secret123";
let jwt = encode(&header, secret.to_string(), &payload, Algorithm::HS256);

//RS256
use std::env;

let mut payload = json!({
    "key1" : "val1",
    "key2" : "val2"
});
let mut header = json!({});
let mut keypath = env::current_dir().unwrap();
keypath.push("some_folder");
keypath.push("my_rsa_2048_key.pem");
let jwt = encode(&header, &keypath.to_path_buf(), &payload, Algorithm::RS256);
let (header, payload) = decode(&jwt, &keypath.to_path_buf(), Algorithm::RS256);

License

Original project code (frank_jwt) was licensed under the Apache 2.0 license. New code is being written under the LGPL 3.0. Eventually all original code will be re-rewitten and entire project will be LGPL'd.

Commit count: 149

cargo fmt