Authex.Token (Authex v2.2.0) View Source

A struct wrapper for token claims.

Typically, we shouldnt need to directly interact with this module. Rather, we should use the Authex.token/3 function.

Link to this section Summary

Functions

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

Link to this section Types

Specs

claim() ::
  {:sub, binary() | integer()}
  | {:aud, binary()}
  | {:iss, binary()}
  | {:jti, binary()}
  | {:scopes, list()}
  | {:meta, map()}

Specs

claims() :: [claim()]

Specs

compact() :: binary()

Specs

option() :: {:time, integer()} | {:ttl, integer() | :infinity}

Specs

options() :: [option()]

Specs

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(module, claims \\ [], opts \\ [])

View Source

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

Options

  • :time - the base time (timestamp format) in which to use.
  • :ttl - the TTL for the token or :infinity if no expiration is required.

Examples

Authex.Token.new(MyApp.Auth, [sub: 1], [ttl: 60])