FdsnPlugs.JwkConfig (fdsn_plugs v0.9.3)
View SourceReads JWT authority configurations from the JWT_AUTHORITIES environment
variable and returns child specs suitable for a supervision tree.
Format
The env var must be a JSON array of objects. Each object requires a "name"
and a "jwks_url". The optional "time_interval" defaults to 600 000 ms
(10 minutes). first_fetch_sync is always set to true.
export JWT_AUTHORITIES='[
{"name":"eida","jwks_url":"https://geofon.gfz.de/eas2/jwk"},
{"name":"other","jwks_url":"https://auth.example.com/jwks","time_interval":3600000}
]'
If the env var is unset, empty, or invalid, child_specs/0 returns an empty
list — no strategies are started.
Usage in a supervision tree
children =
FdsnPlugs.JwkConfig.child_specs() ++ [
# your other children…
]
Supervisor.start_link(children, strategy: :one_for_one)
Summary
Functions
Returns the list of authority atom names from the JWT_AUTHORITIES env var.
Returns a list of FdsnPlugs.JwkStrategy child specs read from the
JWT_AUTHORITIES environment variable.
Like child_specs/0 but accepts an explicit list of authority maps for
testing or programmatic use.
Functions
@spec authority_names() :: [atom()]
Returns the list of authority atom names from the JWT_AUTHORITIES env var.
Useful for configuring FdsnPlugs.JWTAuthentication:
config :fdsn_plugs, :jwt_authorities, FdsnPlugs.JwkConfig.authority_names()
@spec child_specs() :: [Supervisor.child_spec()]
Returns a list of FdsnPlugs.JwkStrategy child specs read from the
JWT_AUTHORITIES environment variable.
Returns [] when the env var is not set, empty, or contains invalid JSON.
@spec child_specs([map()]) :: [Supervisor.child_spec()]
Like child_specs/0 but accepts an explicit list of authority maps for
testing or programmatic use.
FdsnPlugs.JwkConfig.child_specs([
%{name: :eida, jwks_url: "https://geofon.gfz.de/eas2/jwk"}
])