ProtoRune. Security. TokenStore behaviour
(proto_rune v0.5.2)
Copy Markdown
Behaviour for pluggable token storage backends.
A backend persists opaque, already-encrypted blobs keyed by an account
identifier (typically the account DID). Backends never see plaintext
tokens: encryption and decryption happen in ProtoRune.Security
before the blob reaches the store.
ProtoRune.Security.TokenStore.Dets is the default implementation.
Implement this behaviour to store tokens elsewhere (a database, a
system keyring, Redis, etc):
defmodule MyApp.DBTokenStore do
@behaviour ProtoRune.Security.TokenStore
@impl true
def put(id, blob, _opts), do: MyApp.Repo.upsert_token(id, blob)
@impl true
def fetch(id, _opts), do: MyApp.Repo.get_token(id)
@impl true
def delete(id, _opts), do: MyApp.Repo.delete_token(id)
endThen pass {MyApp.DBTokenStore, []} as the store argument to the
ProtoRune.Security functions.
Summary
Types
A storage backend and its options.
Account identifier used as the storage key, typically a DID.
Backend-specific options.
Callbacks
Deletes the entry stored under id. Deleting a missing entry returns :ok.
Fetches the blob stored under id.
Persists the encrypted blob under id, overwriting any existing entry.
Types
Callbacks
Deletes the entry stored under id. Deleting a missing entry returns :ok.
Fetches the blob stored under id.
Returns {:error, :not_found} when no entry exists for id.
Persists the encrypted blob under id, overwriting any existing entry.