NoWayJose.Jwks.Fetcher (NoWayJose v1.0.2)
View SourceGenServer that periodically fetches and caches JWKS from a remote endpoint.
Options
:name(required) - Unique identifier for this fetcher:url(required) - JWKS endpoint URL:refresh_interval- Refresh period in ms (default: 15 minutes):retry_interval- Retry period on failure in ms (default: 30 seconds):sync_init- Block until first fetch completes (default: false):http_client- Module implementingNoWayJose.Jwks.HttpClientbehaviour:http_opts- Options passed to the HTTP client
Telemetry Events
The fetcher emits the following telemetry events:
[:no_way_jose, :jwks, :fetch, :start]- Fetch started- Metadata:
%{name: name, url: url}
- Metadata:
[:no_way_jose, :jwks, :fetch, :stop]- Fetch completed successfully- Measurements:
%{duration: native_time} - Metadata:
%{name: name, url: url, key_count: count}
- Measurements:
[:no_way_jose, :jwks, :fetch, :exception]- Fetch failed- Measurements:
%{duration: native_time} - Metadata:
%{name: name, url: url, reason: reason}
- Measurements:
Summary
Functions
Returns a specification to start this module under a supervisor.
Returns the current state of the fetcher (for debugging).
Triggers an immediate refresh of the JWKS.
Starts a JWKS fetcher.
Returns the via tuple for a fetcher.
Types
@type option() :: {:name, String.t()} | {:url, String.t()} | {:refresh_interval, non_neg_integer()} | {:retry_interval, non_neg_integer()} | {:sync_init, boolean()} | {:http_client, module()} | {:http_opts, keyword()}
@type options() :: [option()]
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Returns the current state of the fetcher (for debugging).
@spec refresh(String.t()) :: :ok
Triggers an immediate refresh of the JWKS.
@spec start_link(options()) :: GenServer.on_start()
Starts a JWKS fetcher.
Examples
# Async start (returns immediately, fetches in background)
{:ok, pid} = NoWayJose.Jwks.Fetcher.start_link(
name: "auth0",
url: "https://example.auth0.com/.well-known/jwks.json"
)
# Sync start (blocks until first fetch completes)
{:ok, pid} = NoWayJose.Jwks.Fetcher.start_link(
name: "google",
url: "https://www.googleapis.com/oauth2/v3/certs",
sync_init: true
)
Returns the via tuple for a fetcher.