No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
LICENSE
Makefile
README.md
rebar
rebar.config

README.md

Erlang JWT Library

JWT is a simple authorization token format based on JSON. Peter Hizalev wrote this library at Kato.im. We're open-sourcing it in case someone else needs to create or parse JWT tokens with Erlang.

Smoke test example

Install

git clone git@github.com:kato-im/ejwt.git && cd ejwt
./rebar get-deps
erl

In Erlang shell:

%% Create JWT token
application:start(crypto).
Key = <<"53F61451CAD6231FDCF6859C6D5B88C1EBD5DC38B9F7EBD990FADD4EB8EB9063">>.
Claims = {[
    {user_id, <<"bob123">>},
    {user_name, <<"Bob">>}
]}.
ExpirationSeconds = 86400,
Token = ejwt:jwt(<<"HS256">>, Claims, ExpirationSeconds, Key).

%% Parse JWT token
ejwt:parse_jwt(Token, Key).

You should get back the original claims Jterm, plus expiration claim:

{[
    {<<"exp">>,1392607527},
    {<<"user_id">>,<<"bob123">>},
    {<<"user_name">>,<<"Bob">>}
]}