Fix Sourcehut link
Bump version to 0.2.0
Update fields to follow JWT spec
A simple and easy to use JWT library. This is a convenient wrapper around jose.
I made this library so I wouldn't have to write the same JWT module for every app I make. foodog includes sensible defaults and the ability to override them. The default field names are based on the JWT standard.
Generated tokens include these fields by default:
Verifying tokens will by default:
rebar3 compile
rebar3 eunit
rebar3 ct
Set these config variables:
{foodog, [{issuer, <<"example.com">>},
{keys, [{<<"kid1">>, <<"1234567">>}]}]}.
The keys field is a proplist to make key rotations seamless. foodog will by default use the first key in the propslist to generate the token. When verifying it will lookup in the proplist for the key used to sign the token.
To seamlessly rotate a key, add your new key to the top of the proplist. After a given amount of time that all sessions using the old key are closed, simply remove the old key from the proplist.
Then generate and verify JWT's like this:
{ok, Token} = foodog:generate(#{<<"foobar">> => <<"barfoo">>}),
{ok, Payload} = foodog:verify(Token)
You can override the defaults by passing in an options map.
Options = #{exp => {hours, 2},
iss => <<"example2.com">>},
{ok, Token} = foodog:generate(#{<<"foo">> => <<"bar">>}, Options),
{ok, Payload} = foodog:verify(Token, Options).
The default expiration time for a token is 1 hour.
This can be adjusted by passing in arg to generate like this:
{ok, Token} = foodog:generate(Payload, {hours, 2}).
This will make a token that is good for 2 hours.
foodog supports these expiration time intervals:
Apache V2