barrel_mcp_client_auth_store behaviour (barrel_mcp v3.0.0)

View Source

Persistence for what an OAuth client handle learns: the client it registered (or was given) and the tokens it holds.

Without a store both live in the handle and die with the client process. A host that wants them to survive a restart gives the {oauth, Config} a store => {Module, Arg} implementing this behaviour. Keys are client and tokens; values are maps the handle owns the shape of.

Deleting matters as much as writing: when the resource's authorization server changes, the handle drops both and registers again, and a store that ignored the delete would hand the old credential back on the next start.

Summary

Functions

Read Key from Store, Default without one or when unset.

Types

key/0

-type key() :: client | tokens.

store/0

-type store() :: {module(), term()} | undefined.

Callbacks

delete/2

-callback delete(key(), Arg :: term()) -> ok.

get/2

-callback get(key(), Arg :: term()) -> {ok, map()} | undefined.

put/3

-callback put(key(), map(), Arg :: term()) -> ok.

Functions

delete(_, Key)

-spec delete(store(), key()) -> ok.

get(_, Key, Default)

-spec get(store(), key(), map() | undefined) -> map() | undefined.

Read Key from Store, Default without one or when unset.

put(_, Key, Value)

-spec put(store(), key(), map()) -> ok.