livery_auth_oidc (livery v0.13.0)
View SourceOIDC provider discovery.
discover/1,2 fetches an issuer's
/.well-known/openid-configuration document and returns it as a
decoded map (notably jwks_uri, issuer, authorization_endpoint,
token_endpoint). Feed the jwks_uri to livery_auth_jwks:keys/1
to get verification keys. discover_oauth/1,2 does the same for an
OAuth 2.0 authorization server's metadata (RFC 8414).
The document's issuer must be exactly the issuer you passed, as
OpenID Connect Discovery 1.0 section 4.3 requires. Otherwise you get
{error, issuer_mismatch}, or {error, invalid_discovery} when it
names none.
Deviations: only issuer is checked; the other REQUIRED metadata
fields are returned as the provider sent them. See AGENTS.md, Known deviations.
The HTTP fetch is pluggable via fetch => fun((Url) -> {ok, Body} | {error, _}); the default uses livery_auth_jwks:default_fetch/1
(hackney).
{ok, Cfg} = livery_auth_oidc:discover(<<"https://issuer.example">>),
JwksUri = maps:get(<<"jwks_uri">>, Cfg),
{ok, Keys} = livery_auth_jwks:keys(JwksUri).
Summary
Functions
Fetch and parse the OIDC discovery document for an issuer.
Fetch and parse an OAuth 2.0 authorization server's metadata (RFC 8414)
for an issuer. Same checks and errors as discover/2.
Build the RFC 8414 metadata URL for an issuer. The well-known segment
goes between the host and the issuer's path (RFC 8414 3.1), so
https://as.example/tenant becomes
https://as.example/.well-known/oauth-authorization-server/tenant.
Build the discovery URL for an issuer (handles a trailing slash).
Types
Functions
Fetch and parse the OIDC discovery document for an issuer.
Fetch and parse an OAuth 2.0 authorization server's metadata (RFC 8414)
for an issuer. Same checks and errors as discover/2.
Build the RFC 8414 metadata URL for an issuer. The well-known segment
goes between the host and the issuer's path (RFC 8414 3.1), so
https://as.example/tenant becomes
https://as.example/.well-known/oauth-authorization-server/tenant.
Build the discovery URL for an issuer (handles a trailing slash).