OpenID Connect UserInfo claim resolution and scope-gated release (OpenID Connect Core 1.0 §5.3 / §5.4 / §5.5), as conn-free core.
Verifies that the authenticated access-token claims carry the openid scope
(OIDC Core §5.3.1), invokes the host's :build_userinfo_claims callback,
filters the returned claims to those authorized by the granted scopes (§5.4)
or individually requested via claims.userinfo (§5.5), and pins sub to the
verified token subject (§5.3.2).
Individually requested claims are honoured only when the provider supports
the claims request parameter (:claims_parameter_supported). Otherwise a
claims object recorded on the access token is ignored: the host callback
receives %{} and only the scope-implied claims are released.
The scope-implied set is the OIDC Core §5.4 mapping, widened by the host's
:userinfo_scope_claims (extra claim names per scope) and
:userinfo_always_claims (released for every openid token).
The host callback may also answer {:error, :invalid_token} for a subject
that is no longer entitled to a response, for example one disabled after
the access token was minted.
Summary
Functions
Resolve and shape the UserInfo response map for verified access-token claims.
Decide the form of the UserInfo response for the client the access token was issued to (OpenID Connect Core §5.3.2).
Whether signed UserInfo responses are possible: the host configured
:client_userinfo_signed_response_alg.
The algorithms a UserInfo response can be signed with, or nil when signed
responses are not configured. For userinfo_signing_alg_values_supported.
The OIDC Core §5.4 scope-to-claim mapping, before any host additions.
Validate the host's :userinfo_scope_claims and :userinfo_always_claims.
Functions
@spec resolve_claims(AttestoPhoenix.Config.t(), map()) :: {:ok, map()} | {:error, :insufficient_scope | :invalid_token}
Resolve and shape the UserInfo response map for verified access-token claims.
Returns {:ok, userinfo_map}, {:error, :insufficient_scope} when the
access token lacks the openid scope, or {:error, :invalid_token} when the
host's claim source refuses the subject.
@spec response(AttestoPhoenix.Config.t(), map(), map()) :: :json | {:jwt, String.t()} | {:error, :unsupported_alg | :client_unavailable}
Decide the form of the UserInfo response for the client the access token was issued to (OpenID Connect Core §5.3.2).
Returns :json for a client with no registered
userinfo_signed_response_alg (and always when the host did not configure
the callback, in which case no client is loaded), {:jwt, compact_jws} for a
client that registered the algorithm this server signs with, and
{:error, :unsupported_alg | :client_unavailable} when the client
registered another algorithm or can no longer be loaded. A client that asked
for a signed response is never answered with unsigned JSON.
@spec signed_responses?(AttestoPhoenix.Config.t()) :: boolean()
Whether signed UserInfo responses are possible: the host configured
:client_userinfo_signed_response_alg.
@spec signing_alg_values(AttestoPhoenix.Config.t()) :: [String.t()] | nil
The algorithms a UserInfo response can be signed with, or nil when signed
responses are not configured. For userinfo_signing_alg_values_supported.
The OIDC Core §5.4 scope-to-claim mapping, before any host additions.
Validate the host's :userinfo_scope_claims and :userinfo_always_claims.
scope_claims must be a map from scope to a list of claim names, and
always_claims a list of claim names. sub is refused in both: it is always
released and always the verified token subject (§5.3.2). When
claims_supported is non-empty, every configured name must appear in it.
Raises ArgumentError naming the offending key.