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

provider()

@type provider() :: {:provider, module(), server_ref()}

provider_binding()

@type provider_binding() :: server_ref() | {server_ref(), scope()} | struct()

scope()

@type scope() :: :server | :public | {:session, String.t()}

server_ref()

@type server_ref() :: GenServer.server()

token_input()

@type token_input() ::
  ArchAstro.Auth.TokenSet.t() | ArchAstro.JSON.object() | struct()

Callbacks

authorization(provider_binding)

@callback authorization(provider_binding()) ::
  {:ok, ArchAstro.Authorization.t()} | {:error, ArchAstro.Error.reason()}

bind(server_ref, scope)

@callback bind(server_ref(), scope()) ::
  {:ok, provider_binding()} | {:error, ArchAstro.Error.reason()}

delete_session(server_ref, t)

@callback delete_session(server_ref(), String.t()) ::
  :ok | {:error, ArchAstro.Error.reason()}

put_session(server_ref, t, t)

@callback put_session(server_ref(), String.t(), ArchAstro.Auth.TokenSet.t()) ::
  :ok | {:error, ArchAstro.Error.reason()}

refresh_if_current(provider_binding, non_neg_integer)

@callback refresh_if_current(provider_binding(), non_neg_integer()) ::
  {:ok, ArchAstro.Authorization.t()} | {:error, ArchAstro.Error.reason()}

Functions

authorization(binding)

@spec authorization(ArchAstro.TokenServer.Binding.t()) ::
  {:ok, ArchAstro.Authorization.t()} | {:error, ArchAstro.Error.reason()}

bind(server, scope)

@spec bind(provider() | server_ref(), scope()) ::
  {:ok, ArchAstro.TokenServer.Binding.t()} | {:error, ArchAstro.Error.reason()}

delete_session(server, session_id)

@spec delete_session(provider() | server_ref(), String.t()) ::
  :ok | {:error, ArchAstro.Error.reason()}

put_session(server, session_id, tokens)

@spec put_session(provider() | server_ref(), String.t(), token_input()) ::
  :ok | {:error, ArchAstro.Error.reason()}

refresh_if_current(binding, generation)

@spec refresh_if_current(ArchAstro.TokenServer.Binding.t(), non_neg_integer()) ::
  {:ok, ArchAstro.Authorization.t()} | {:error, ArchAstro.Error.reason()}