ArchAstro. TokenServer behaviour
(archastro v0.2.0)
Copy Markdown
Behaviour and dispatch API for immutable-client credential providers.
Implementations bind a client to an explicit credential scope. A secret-key provider must reject every session scope rather than falling back to its privileged server credential.
Summary
Types
@type provider() :: {:provider, module(), server_ref()}
@type provider_binding() :: server_ref() | {server_ref(), scope()} | struct()
@type scope() :: :server | :public | {:session, String.t()}
@type server_ref() :: GenServer.server()
@type token_input() :: ArchAstro.Auth.TokenSet.t() | ArchAstro.JSON.object() | struct()
Callbacks
@callback authorization(provider_binding()) :: {:ok, ArchAstro.Authorization.t()} | {:error, ArchAstro.Error.reason()}
@callback bind(server_ref(), scope()) :: {:ok, provider_binding()} | {:error, ArchAstro.Error.reason()}
@callback delete_session(server_ref(), String.t()) :: :ok | {:error, ArchAstro.Error.reason()}
@callback put_session(server_ref(), String.t(), ArchAstro.Auth.TokenSet.t()) :: :ok | {:error, ArchAstro.Error.reason()}
@callback refresh_if_current(provider_binding(), non_neg_integer()) :: {:ok, ArchAstro.Authorization.t()} | {:error, ArchAstro.Error.reason()}
Functions
@spec authorization(ArchAstro.TokenServer.Binding.t()) :: {:ok, ArchAstro.Authorization.t()} | {:error, ArchAstro.Error.reason()}
@spec bind(provider() | server_ref(), scope()) :: {:ok, ArchAstro.TokenServer.Binding.t()} | {:error, ArchAstro.Error.reason()}
@spec delete_session(provider() | server_ref(), String.t()) :: :ok | {:error, ArchAstro.Error.reason()}
@spec put_session(provider() | server_ref(), String.t(), token_input()) :: :ok | {:error, ArchAstro.Error.reason()}
@spec refresh_if_current(ArchAstro.TokenServer.Binding.t(), non_neg_integer()) :: {:ok, ArchAstro.Authorization.t()} | {:error, ArchAstro.Error.reason()}