View Source Pow.Plug.MessageVerifier behaviour (Pow v1.0.39)

This module can sign and verify messages.

Based on Phoenix.Token.

Summary

Callbacks

sign(t, binary, binary, keyword)

@callback sign(Plug.Conn.t(), binary(), binary(), keyword()) :: binary()

verify(t, binary, binary, keyword)

@callback verify(Plug.Conn.t(), binary(), binary(), keyword()) :: {:ok, binary()} | :error

Functions

sign(conn, salt, message, config)

@spec sign(Plug.Conn.t(), binary(), binary(), keyword()) :: binary()

Signs a message.

Plug.Crypto.MessageVerifier.sign/2 is used. The secret is derived from the salt and conn.secret_key_base using Plug.Crypto.KeyGenerator.generate/3. If :key_generator_opts is set in the config, this will be passed on to Plug.Crypto.KeyGenerator.

verify(conn, salt, message, config)

@spec verify(Plug.Conn.t(), binary(), binary(), keyword()) :: {:ok, binary()} | :error

Verifies a message.

Plug.Crypto.MessageVerifier.sign/2 is used. The secret is derived from the salt and conn.secret_key_base using Plug.Crypto.KeyGenerator.generate/3. If :key_generator_opts is set in the config, this will be passed on to Plug.Crypto.KeyGenerator.