Authex.Repo behaviour (Authex v2.2.0) 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
Specs
Specs
t() :: module() | false
Link to this section Callbacks
Specs
delete(key()) :: :ok | :error
Deletes a binary key from the repo.
Returns :ok
on success, or :error
on error.
Specs
Checks if a binary key exists in the repo.
Returns a boolean, or :error
Specs
insert(key()) :: :ok | :error
Inserts a binary key into the repo.
Returns :ok
on success, or :error
on error.