8000 GitHub - reklis/frank_jwt: JSON Web Token implementation in Rust.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

reklis/frank_jwt

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

JSON Web Token implementation in Rust.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%
0