AshAuthentication.Firebase.TokenVerifier.KeyStoreBehaviour behaviour (ash_authentication_firebase v1.1.0)

Copy Markdown View Source

Behaviour for modules that supply Firebase public keys to the token verifier.

Summary

Callbacks

Returns the currently cached Firebase public keys, keyed by kid.

Forces a synchronous refresh of the cached keys.

Callbacks

get_keys()

@callback get_keys() :: {:ok, %{optional(String.t()) => JOSE.JWK.t()}} | {:error, term()}

Returns the currently cached Firebase public keys, keyed by kid.

Implementations must not block — this is called on the hot path of every token verification. Before the first successful fetch completes the call may return {:error, :not_initialized}; the token verifier interprets that as a cache miss and falls back to refresh_now/0.

refresh_now()

@callback refresh_now() :: :ok | {:error, term()}

Forces a synchronous refresh of the cached keys.

Used by the token verifier on a kid miss to recover from Google key rotation between scheduled refreshes. The call blocks until the fetch finishes (or times out) and is expected to be debounced inside the implementation so that repeated cache misses cannot hammer Google.