Module jwt

JWT Library for Erlang.

Description

JWT Library for Erlang.

Written by Peter Hizalev at Kato (http://kato.im)

Rewritten by Yuri Artemev (http://artemff.com)

Data Types

expiration()

expiration() = {hourly, non_neg_integer()} | {daily, non_neg_integer()} | non_neg_integer()

Function Index

decode/2Decodes a token, checks the signature and returns the content of the token.
decode/3Decode with an issuer key mapping.
encode/3Creates a token from given data and signs it with a given secret.
encode/4Creates a token from given data and signs it with a given secret.

Function Details

decode/2

decode(Token::binary(), Key::binary() | public_key:public_key() | public_key:private_key()) -> {ok, Claims::map()} | {error, any()}

Decodes a token, checks the signature and returns the content of the token

decode/3

decode(Token::binary(), DefaultKey::binary() | public_key:public_key() | public_key:private_key(), IssuerKeyMapping::map()) -> {ok, Claims::map()} | {error, any()}

Decode with an issuer key mapping

Receives the issuer key mapping as the last parameter

encode/3

encode(Alg::binary(), ClaimsSet::map() | list(), Key::binary() | public_key:private_key()) -> {ok, Token::binary()} | {error, any()}

Creates a token from given data and signs it with a given secret

Parameters are

encode/4

encode(Alg::binary(), ClaimsSet::map() | list(), Expiration::expiration(), Key::binary() | public_key:private_key()) -> {ok, Token::binary()} | {error, any()}

Creates a token from given data and signs it with a given secret

and also adds exp claim to payload

Expiration can be one of the tuples: {hourly, SecondsAfterBeginningOfCurrentHour}, {daily, SecondsAfterBeginningOfCurrentDay} or can be just an integer representing the amount of seconds the token will live


Generated by EDoc