/rust-jwt

Rust implementation of JSON Web Tokens

Primary LanguageRustMIT LicenseMIT

rust-jwt

Build Status Rust implementation of JSON Web Tokens

Usable, but not production ready. Hasn't been audited for security and the API will change.

Usage

Add this to your Cargo.toml:

[dependencies.jwt]

git = "https://github.com/stygstra/rust-jwt"

Example:

extern crate jwt;
use jwt::Claims;
use jwt::jws::hs256::{encode, decode};

fn main() {
    let mut claims = Claims::new();
    claims.insert_unsafe("com.example.my-claim", "value".to_string());
    let token = encode(&claims, b"secret");
    let decoded = decode(&*token, b"secret").unwrap();
    assert_eq!(claims, decoded);
    println!("ok");
}

Todo

Documentation

View documentation.