View Source Authex.Repo behaviour (Authex v2.3.0)

Defines a verification repo.

This allows for the creation of persistent storage for blacklists. Blacklists are used to block usage of a token by its :jti key.

defmodule MyApp.Auth.Blacklist do
  @behaviour Authex.Repo

  @impl Authex.Repo
  def exists?(key) do
    # Check if the key exists in the repo.
  end

  @impl Authex.Repo
  def insert(key) do
    # Insert the key in the repo.
  end

  @impl Authex.Repo
  def delete(key) do
    # Delete the key from the repo.
  end
end

Please be aware of the performance penalty that may be incurred if using blacklists during the auth verification process. This will largely depend on the storage medium used.

Link to this section Summary

Callbacks

Deletes a binary key from the repo.

Checks if a binary key exists in the repo.

Inserts a binary key into the repo.

Link to this section Types

Link to this section Callbacks

@callback delete(key()) :: :ok | :error

Deletes a binary key from the repo.

Returns :ok on success, or :error on error.

@callback exists?(key()) :: boolean() | :error

Checks if a binary key exists in the repo.

Returns a boolean, or :error

@callback insert(key()) :: :ok | :error

Inserts a binary key into the repo.

Returns :ok on success, or :error on error.