Guardian v2.1.1 Guardian.Token behaviour View Source
The behaviour module for all token modules.
Token modules are responsible for all the heavy lifting in Guardian.
Link to this section Summary
Callbacks
Build the default claims for the token
Create the token including serializing and signing
Decode the token. Without verification of the claims within it.
Exchange a token from one type to another
Inspect the contents of the token without validation or signature checking
Refresh a token
Revoke a token (if appropriate)
Generate a unique id for a token
Verify the claims of a token
Link to this section Types
claims()
View Source
claims() :: map()
claims() :: map()
decoding_error()
View Source
decoding_error() :: {:error, atom()}
decoding_error() :: {:error, atom()}
encoding_error()
View Source
encoding_error() :: {:error, atom()}
encoding_error() :: {:error, atom()}
resource()
View Source
resource() :: any()
resource() :: any()
secret_error()
View Source
secret_error() :: {:error, :secret_not_found}
secret_error() :: {:error, :secret_not_found}
signing_error()
View Source
signing_error() :: {:error, :signing_error}
signing_error() :: {:error, :signing_error}
token()
View Source
token() :: String.t()
token() :: String.t()
ttl()
View Source
ttl() ::
{pos_integer(), :second}
| {pos_integer(), :seconds}
| {pos_integer(), :minute}
| {pos_integer(), :minutes}
| {pos_integer(), :hour}
| {pos_integer(), :hours}
| {pos_integer(), :day}
| {pos_integer(), :days}
| {pos_integer(), :week}
| {pos_integer(), :weeks}
ttl() :: {pos_integer(), :second} | {pos_integer(), :seconds} | {pos_integer(), :minute} | {pos_integer(), :minutes} | {pos_integer(), :hour} | {pos_integer(), :hours} | {pos_integer(), :day} | {pos_integer(), :days} | {pos_integer(), :week} | {pos_integer(), :weeks}
Link to this section Callbacks
build_claims(mod, resource, sub, claims, options) View Source
Build the default claims for the token
create_token(mod, claims, options)
View Source
create_token(mod :: module(), claims :: claims(), options :: Guardian.options()) ::
{:ok, token()} | signing_error() | secret_error() | encoding_error()
create_token(mod :: module(), claims :: claims(), options :: Guardian.options()) :: {:ok, token()} | signing_error() | secret_error() | encoding_error()
Create the token including serializing and signing
decode_token(mod, token, options)
View Source
decode_token(mod :: module(), token :: token(), options :: Guardian.options()) ::
{:ok, token()} | secret_error() | decoding_error()
decode_token(mod :: module(), token :: token(), options :: Guardian.options()) :: {:ok, token()} | secret_error() | decoding_error()
Decode the token. Without verification of the claims within it.
exchange(mod, old_token, from_type, to_type, options) View Source
Exchange a token from one type to another
peek(module, token) View Source
Inspect the contents of the token without validation or signature checking
refresh(mod, old_token, options) View Source
Refresh a token
revoke(mod, claims, token, options) View Source
Revoke a token (if appropriate)
token_id()
View Source
token_id() :: String.t()
token_id() :: String.t()
Generate a unique id for a token
verify_claims(mod, claims, options)
View Source
verify_claims(
mod :: module(),
claims :: claims(),
options :: Guardian.options()
) :: {:ok, claims()} | {:error, any()}
verify_claims( mod :: module(), claims :: claims(), options :: Guardian.options() ) :: {:ok, claims()} | {:error, any()}
Verify the claims of a token