authex v0.1.1 Authex.Verifier View Source

Link to this section Summary

Functions

Creates a new Authex.Verifier struct from the compact token and options

Runs an Authex.Verifier struct - checking that the token is valid

Link to this section Types

Link to this type t() View Source
t() :: %Authex.Verifier{alg: integer(), blacklist: binary(), compact: binary(), jwk: integer(), time: integer()}

Link to this section Functions

Link to this function new(compact, options \\ []) View Source
new(binary(), list()) :: Authex.Verifier.t()

Creates a new Authex.Verifier struct from the compact token and options.

Parameters

  • compact: A binary compact token.
  • options: A keyword list of options.

Options

  • :time - the base time (timestamp format) in which to use.
  • :secret - the secret to verify the token with.
  • :alg - the algorithm to verify the token with.
  • :blacklist - the blacklist module to check the jti claim with.

Examples

iex> verifier = Authex.Verifier.new("token")
iex> with %Authex.Verifier{compact: compact} <- verifier, do: compact
"token"
Link to this function run(verifier) View Source
run(t()) :: {:ok, Authex.Token.t()} | {:error, atom()}

Runs an Authex.Verifier struct - checking that the token is valid.

Parameters

  • verifier: An Authex.Verifier struct.

Examples

iex> {:ok, token} = [sub: 1]
...> |> Authex.token()
...> |> Authex.sign()
...> |> Authex.Verifier.new()
...> |> Authex.Verifier.run()
iex> with %Authex.Token{sub: sub} <- token, do: sub
1