Assent.JWTAdapter behaviour (Assent v0.1.27) View Source

JWT adapter helper module.

Usage

defmodule MyApp.MyJWTAdapter do
  @behaviour Assent.JWTAdapter

  @impl true
  def sign(claims, alg, secret, opts) do
    # ...
  end

  @impl true
  def verify(token, secret, opts) do
    # ...
  end
end

Link to this section Summary

Functions

Loads a private key from the provided configuration

Generates a signed JSON Web Token signature

Verifies the JSON Web Token signature

Link to this section Callbacks

Link to this callback

sign(map, binary, binary, t)

View Source

Specs

sign(map(), binary(), binary(), Keyword.t()) ::
  {:ok, binary()} | {:error, any()}

Specs

verify(binary(), binary() | map() | nil, Keyword.t()) ::
  {:ok, map()} | {:error, any()}

Link to this section Functions

Link to this function

load_private_key(config)

View Source

Specs

load_private_key(Assent.Config.t()) :: {:ok, binary()} | {:error, term()}

Loads a private key from the provided configuration

Link to this function

sign(claims, alg, secret, opts \\ [])

View Source

Specs

sign(map(), binary(), binary(), Keyword.t()) ::
  {:ok, binary()} | {:error, term()}

Generates a signed JSON Web Token signature

Link to this function

verify(token, secret, opts \\ [])

View Source

Specs

verify(binary(), binary() | map() | nil, Keyword.t()) ::
  {:ok, map()} | {:error, any()}

Verifies the JSON Web Token signature