Where clients, codes, tokens and consents live. Implemented by Sake.Auth.Store.ETS and Sake.Auth.Store.Ecto.
Summary
Callbacks
Marks a refresh token used now, if and only if it was unused, atomically: two concurrent calls for the same hash must not both succeed. Returns the record as it was before this call.
Forgets the approval for one resource, or for every resource with :all.
Deletes the codes and tokens that expired by now, and the consents
inserted before consents_before whose subject, client and resource
have no live (unexpired, unrevoked) refresh token left.
Remembers an approval, keyed by subject, client and resource (replacing an earlier one).
Types
@type state() :: term()
Callbacks
@callback consume_code(state(), String.t()) :: {:ok, Sake.Auth.Code.t()} | :error
@callback consume_refresh(state(), String.t()) :: {:ok, Sake.Auth.TokenRecord.t()} | {:error, :used, Sake.Auth.TokenRecord.t()} | :error
Marks a refresh token used now, if and only if it was unused, atomically: two concurrent calls for the same hash must not both succeed. Returns the record as it was before this call.
@callback delete_consent( state(), subject_id :: String.t(), client_id :: String.t(), resource :: String.t() | :all ) :: :ok
Forgets the approval for one resource, or for every resource with :all.
@callback get_client(state(), String.t()) :: {:ok, Sake.Auth.Client.t()} | :error
@callback get_consent( state(), subject_id :: String.t(), client_id :: String.t(), resource :: String.t() ) :: {:ok, Sake.Auth.Consent.t()} | :error
@callback get_token(state(), :access | :refresh, String.t()) :: {:ok, Sake.Auth.TokenRecord.t()} | :error
@callback list_clients(state()) :: [Sake.Auth.Client.t()]
@callback prune(state(), now :: DateTime.t(), consents_before :: DateTime.t()) :: :ok
Deletes the codes and tokens that expired by now, and the consents
inserted before consents_before whose subject, client and resource
have no live (unexpired, unrevoked) refresh token left.
@callback put_client(state(), Sake.Auth.Client.t()) :: :ok
@callback put_code(state(), Sake.Auth.Code.t()) :: :ok
@callback put_consent(state(), Sake.Auth.Consent.t()) :: :ok
Remembers an approval, keyed by subject, client and resource (replacing an earlier one).
@callback put_token(state(), Sake.Auth.TokenRecord.t()) :: :ok
@callback tokens_for_subject(state(), String.t()) :: [Sake.Auth.TokenRecord.t()]