View Source CsrfPlus.Token behaviour (CsrfPlus v0.1.2)

Defines the Token behaviour and a DefaultToken module implementation.

Summary

Callbacks

The function to generate a token. It must returns a tuple with the token itself and the signed version of it. In the format {token, signed_token}.

Simply put, must verifies a signed_token.

Functions

Calls the configured Token module to generate a token

Calls the configured Token module to verify a signed_token

Callbacks

@callback generate() :: {String.t(), String.t()}

The function to generate a token. It must returns a tuple with the token itself and the signed version of it. In the format {token, signed_token}.

The signed_token is the token signed with some secret key or crypto algorithm that allows further verification.

@callback verify(signed_token :: String.t()) :: {:ok, String.t()} | {:error, term()}

Simply put, must verifies a signed_token.

Returns {:ok, verified_token} in case of success. Or {:error, the_error_itself}.

The verified_token is the original token before being signed.

Functions

Calls the configured Token module to generate a token

Calls the configured Token module to verify a signed_token