Single-node ETS AttestoPhoenix.ClientIdMetadata.Cache - CIMD
(draft-ietf-oauth-client-id-metadata-document-01, IETF OAuth WG).
Caches a validated Client ID Metadata Document in per-node memory keyed by its
client_id URL. A per-node cache is correct for CIMD - a miss simply
re-fetches and re-validates - so this is the single-node opt-out from the
default AttestoPhoenix.ClientIdMetadata.Cache.Ecto, which a clustered
deployment prefers for cross-node coherence and to bound outbound fetch
fan-out. Select it by configuring :cache under AttestoPhoenix.Config's
:client_id_metadata key.
Only a validated document is ever stored (the caller stores after
Attesto.ClientIdMetadata.validate_document/2 succeeds), and freshness is
re-checked on read against the stored expires_at, so an expired entry is a
:miss and is evicted in passing - never served stale.
Summary
Functions
Evicts the cached document for url, if any.
Evicts every cached document.
Resolves a live cached document for a CIMD client_id URL.
Caches validated metadata for a CIMD client_id URL until expires_at.
Functions
@spec delete(String.t()) :: :ok
Evicts the cached document for url, if any.
A cached CIMD document is otherwise honored until its TTL expires. That is the wrong behavior when the document has been rotated or is believed compromised, since the stale copy keeps authorizing the client — this is the operator's lever for that, and the reason the cache is not write-only.
@spec delete_all() :: :ok
Evicts every cached document.
Beyond bulk operational eviction, this is what gives a test suite a clean
cache between cases: the table now outlives the process that created it (by
design — see ensure_owner/1), so it no longer resets by accident when a
caller terminates.
Resolves a live cached document for a CIMD client_id URL.
Returns {:ok, metadata} for a present, unexpired entry, or :miss when it
is absent or expired. An expired entry is deleted in passing (it can never be
honored again), so freshness is enforced on read, not by sweeping.
@spec put(String.t(), map(), DateTime.t()) :: :ok
Caches validated metadata for a CIMD client_id URL until expires_at.
A re-fetched document supersedes a stale one, so this overwrites any existing
entry for the same url (:ets.insert/2 replaces a set row), keyed by URL.