authex v0.2.2 Authex.Token View Source

Link to this section Summary

Functions

Creates a new Authex.Token struct from the given claims and options

Link to this section Types

Link to this type claim() View Source
claim() ::
  {:sub, binary() | integer()} |
  {:aud, binary()} |
  {:iss, binary()} |
  {:jti, binary()} |
  {:scopes, list()} |
  {:meta, map()}
Link to this type claims() View Source
claims() :: [claim()]
Link to this type compact() View Source
compact() :: binary()
Link to this type option() View Source
option() :: {:time, integer()} | {:ttl, integer()}
Link to this type options() View Source
options() :: [option()]
Link to this type t() View Source
t() :: %Authex.Token{aud: binary() | nil, exp: integer() | nil, iat: integer() | nil, iss: binary() | nil, jti: binary() | nil, meta: map(), nbf: integer() | nil, scopes: list(), sub: binary() | integer() | nil}

Link to this section Functions

Link to this function new(auth, claims \\ [], opts \\ []) View Source

Creates a new Authex.Token struct from the given claims and options

Parameters

  • auth: An Authex module.
  • claims: A keyword list of JWT claims.
  • options: A keyword list of options.

Options

  • :time - the base time (timestamp format) in which to use.
  • :ttl - the TTL for the token.

Examples

iex> token = Authex.Token.new([sub: 1], [ttl: 60])
iex> with %Authex.Token{sub: sub} <- token, do: sub
1