adk_credential_store behaviour (erlang_adk v0.7.0)
View SourceBehaviour and shared types for credential stores.
A credential reference is an opaque, random capability. Stores must also verify the principal and provider scope before returning a credential.
Summary
Types
-type credential() :: adk_auth_provider:credential().
-opaque credential_ref()
-type error_reason() ::
invalid_scope | invalid_credential | not_found | conflict | capacity_reached | unavailable.
Callbacks
-callback compare_and_swap(Handle :: handle(), Principal :: principal(), Provider :: provider_id(), Ref :: credential_ref(), Expected :: credential(), Replacement :: credential()) -> ok | {error, error_reason()}.
-callback delete(Handle :: handle(), Principal :: principal(), Provider :: provider_id(), Ref :: credential_ref()) -> ok | {error, error_reason()}.
-callback fetch(Handle :: handle(), Principal :: principal(), Provider :: provider_id(), Ref :: credential_ref()) -> {ok, credential()} | {error, error_reason()}.
-callback put(Handle :: handle(), Principal :: principal(), Provider :: provider_id(), Credential :: credential()) -> {ok, credential_ref()} | {error, error_reason()}.