JSON Web Token implementation in Rust.
Rust
Latest commit 3b9684e Dec 17, 2016 @GildedHonour update openssl wip
Permalink
Failed to load latest commit information.
src update openssl wip Dec 17, 2016
test RS alg-ms added Jul 13, 2016
.gitignore impr-nts Jun 23, 2015
.travis.yml wip Oct 13, 2015
Cargo.toml update openssl wip Dec 17, 2016
LICENSE lcn: changed Jul 4, 2015
README.md update openssl wip Dec 17, 2016

README.md

Frank JWT Build Status crates.io

Implementation of JSON Web Tokens in Rust.

Algorithms and features supported

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

Usage

Put this into your Cargo.toml:

[dependencies]
frank_jwt = "2.3.1"

And this in your crate root:

extern crate frank_jwt;

use frank_jwt::{Header, Payload, Algorithm, encode, decode};

Example

//HS256
let mut payload = Payload::new();
payload.insert("key1".to_string(), "val1".to_string());
payload.insert("key2".to_string(), "val2".to_string());
let header = Header::new(Algorithm::HS256);
let secret = "secret123";

let jwt = encode(header, secret.to_string(), payload.clone());

//RS256
use std::env;

let mut payload = Payload::new();
payload.insert("key1".to_string(), "val1".to_string());
payload.insert("key2".to_string(), "val2".to_string());
let header = Header::new(Algorithm::RS256);

let mut path = env::current_dir().unwrap();
path.push("some_folder");
path.push("my_rsa_2048_key.pem");
let key_path = path.to_str().unwrap().to_string();

let jwt = encode(header, key_path, payload.clone());

License

Apache 2.0

Tests

cargo test

I'm available for hire

I'm a freelance developer and looking forward to new challenges.

me@gildedhonour.com | gildedhonour.com