PhoenixCap.Token behaviour (PhoenixCap v0.1.0)

Copy Markdown View Source

Behaviour for configured verification token modules.

The configured token module follows the same API shape as Phoenix.Token:

config :phoenix_cap,
  token_module: Phoenix.Token

Custom token modules should implement sign/3 and verify/4 with the same argument order.

Summary

Types

Failure reported by the configured signing module.

Callbacks

Signs the verification payload using the endpoint context and configured salt.

Authenticates the token and returns its payload. Honor the supplied :max_age in seconds.

Types

reason()

@type reason() :: term()

Failure reported by the configured signing module.

Callbacks

sign(term, binary, term)

@callback sign(term(), binary(), term()) :: binary()

Signs the verification payload using the endpoint context and configured salt.

verify(term, binary, binary, keyword)

@callback verify(term(), binary(), binary(), keyword()) ::
  {:ok, term()} | {:error, reason()}

Authenticates the token and returns its payload. Honor the supplied :max_age in seconds.