Authex v2.1.1 Authex.Repo behaviour View Source

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

Link to this callback

delete(key)

View Source
delete(key()) :: :ok | :error

Deletes a binary key from the repo.

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

Link to this callback

exists?(key)

View Source
exists?(key()) :: boolean() | :error

Checks if a binary key exists in the repo.

Returns a boolean, or :error

Link to this callback

insert(key)

View Source
insert(key()) :: :ok | :error

Inserts a binary key into the repo.

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