Authorization endpoint request validation (RFC 6749 §4.1.1, OIDC Core §3.1.2.1, RFC 7636 §4.3).
This module validates the protocol shape of an authorization request that
the transport layer has already parsed out of the query string. It checks the
response_type, the presence of client_id and redirect_uri, the requested
scope (surfacing whether the OpenID Connect openid scope was requested), and
the PKCE parameters (code_challenge + code_challenge_method). It carries
state, nonce, claims, and the optional prompt / max_age / acr_values
parameters through to the normalized result.
It deliberately does NOT:
- authenticate the resource owner or render consent (host policy, performed in the Phoenix layer);
- decide whether the
client_idexists, beyond requiring it to be present; - issue an authorization code (
Attesto.AuthorizationCode.issue/3does that, consuming the normalized request this module returns).
It DOES check redirect_uri against the registered set the caller passes in
:registered_redirect_uris by exact string match (RFC 6749 §3.1.2.3, OIDC
Core §3.1.2.1): the registered set is a fact the host supplies, not a policy
decision this module makes.
Error disposition (OIDC Core §3.1.2.6, RFC 6749 §4.1.2.1)
RFC 6749 §4.1.2.1 and OIDC Core §3.1.2.6 split authorization errors into two classes by where the error may be reported:
{:error, {:direct, reason}}- the requestclient_idorredirect_uriis missing or invalid. The authorization server MUST NOT redirect back to the supplied URI (it is untrusted); the error is shown directly to the user agent. Reasons::invalid_client_id,:missing_redirect_uri,:invalid_redirect_uri,:redirect_uri_not_registered.{:error, {:redirect, error}}- theclient_id/redirect_uripair is trusted but some other parameter is invalid. The server redirects back to the validatedredirect_uriwith anerror(anderror_description) query parameter, echoingstatewhen present. Theerrormap carries::error(the RFC 6749 §4.1.2.1 code),:error_description,:redirect_uri, and:state.
The Phoenix layer turns each class into the correct HTTP response; this core module only classifies.
Summary
Types
The classification of a validation failure (OIDC Core §3.1.2.6).
A redirectable authorization error (RFC 6749 §4.1.2.1).
A normalized, validated authorization request.
Functions
Validate a parsed authorization request parameter map (RFC 6749 §4.1.1, OIDC Core §3.1.2.1, RFC 7636 §4.3).
Types
@type error() :: {:direct, :invalid_client_id | :missing_redirect_uri | :invalid_redirect_uri | :redirect_uri_not_registered} | {:redirect, redirect_error()}
The classification of a validation failure (OIDC Core §3.1.2.6).
@type redirect_error() :: %{ error: String.t(), error_description: String.t(), redirect_uri: String.t(), state: String.t() | nil }
A redirectable authorization error (RFC 6749 §4.1.2.1).
@type t() :: %Attesto.AuthorizationRequest{ acr_values: [String.t()], claims: map(), client_id: String.t(), code_challenge: String.t() | nil, code_challenge_method: String.t() | nil, max_age: non_neg_integer() | nil, nonce: String.t() | nil, openid?: boolean(), prompt: [String.t()], redirect_uri: String.t(), response_type: String.t(), scope: [String.t()], state: String.t() | nil }
A normalized, validated authorization request.
The binding fields (client_id, redirect_uri, scope, code_challenge,
code_challenge_method, nonce) line up with the attrs
Attesto.AuthorizationCode.issue/3 consumes.
Functions
Validate a parsed authorization request parameter map (RFC 6749 §4.1.1, OIDC Core §3.1.2.1, RFC 7636 §4.3).
params is a string-keyed map of the authorization request query parameters.
Options
:registered_redirect_uris(required) - the list of redirect URIs registered for the client. The requestredirect_uriMUST be an exact string match against one of these (RFC 6749 §3.1.2.3, OIDC Core §3.1.2.1). An empty list rejects every request with{:direct, :redirect_uri_not_registered}.:require_nonce(optional, defaultfalse) - whentrue, a request with nononceis rejected with a redirectableinvalid_requesterror (OIDC Core §3.1.2.1). Whenfalse,noncestays OPTIONAL and is carried through unenforced (RFC 6749 keepscodeat SHOULD). The host sets this per its own OP policy.:require_pkce(optional, defaulttrue) - whentrue, a request with nocode_challengeis rejected with a redirectableinvalid_requesterror (RFC 7636 §4.3). Whenfalse, an absentcode_challengeis permitted and the validated request carries none. The caller MUST passfalseonly for a confidential client: RFC 9700 §2.1.1 keeps PKCE a MUST for public clients. Acode_challengethat IS present is fully enforced (S256, noplain) regardless of this flag - presence means the client opted into PKCE, so a downgrade is always rejected.:request_object_policy(optional, default%Attesto.RequestObject.Policy{})- the JAR verification policy for a signed
requestobject (RFC 9101), threaded intoAttesto.RequestObject.verify/3. The default is the generic OpenID Connect §6.1 baseline (nbf/exp/typnot required). For FAPI 2.0 Message Signing §5.3.1 passAttesto.RequestObject.Policy.fapi_message_signing/0and set:request_object_audienceto the AS issuer. Has no effect unless arequestobject is present.
- the JAR verification policy for a signed
Returns {:ok, %Attesto.AuthorizationRequest{}} or {:error, error()}, where
error() is classified per the moduledoc.
The client_id / redirect_uri checks run first, because their failure is
non-redirectable (OIDC Core §3.1.2.6): only once a trusted redirect_uri is
established may any further error be reported by redirecting to it.