Verify and redeem Identity Assertion JWT Authorization Grants (ID-JAGs) at the resource authorization server. ID-JAG draft -06, §4.4.
The token endpoint accepts registered confidential clients and client ID
metadata document clients authenticated with RFC 7523 private-key JWT.
It requires authentication by default. Setting jwt_bearer: [public_clients: :allow]
permits public clients, including clients with bearer assertions. Accepting
an unauthenticated request with a bearer ID-JAG departs from draft -06 §4.4.
The token request is no longer bound to a client credential. The assertion's
client_id binding, issuer signature, short lifetime, and jti replay check
still apply.
A host can configure trusted issuers by exact identifier or resolve them from its own trust records. Remote issuer keys use the SSRF-guarded fetcher and cache shared with client ID metadata. Assertion headers never supply verification keys or key URLs.
The token endpoint maps missing assertions to invalid_request, assertion
validation failures to invalid_grant, and subject denials to access_denied
(RFC 6749 §5.2 and ID-JAG draft -06 §4.4.3).
Summary
Types
A verified assertion's fixed-size replay identity and remaining acceptance window.
The resolved local subject, the assertion's scope ceiling (nil when the
assertion carried no scope claim, so the host policy alone decides), and the
validated claims.
Functions
Validate the ID-JAG assertion, claim its replay identity, and resolve the
local subject.
Atomically claim a replay identity returned by prepare/3 before minting.
Validate an ID-JAG while deferring subject resolution and its atomic replay claim.
Prepare an assertion using the request client supplied to the issuer resolver.
prepare/3 supplies the client identifier when only that identifier is available.
Resolve verified ID-JAG claims to a local principal subject.
Types
@type error() ::
:missing_assertion
| :untrusted_issuer
| :jwks_unavailable
| :invalid_assertion
| :replay
| :subject_denied
@type pending_claim() :: {String.t(), pos_integer()}
A verified assertion's fixed-size replay identity and remaining acceptance window.
@type prepared_result() :: %{ scope_ceiling: [String.t()] | nil, claims: Attesto.IdentityAssertion.claims(), issuer_context: term(), replay_claim: pending_claim() }
@type result() :: %{ subject: String.t(), scope_ceiling: [String.t()] | nil, claims: Attesto.IdentityAssertion.claims() }
The resolved local subject, the assertion's scope ceiling (nil when the
assertion carried no scope claim, so the host policy alone decides), and the
validated claims.
Functions
@spec authorize(AttestoPhoenix.Config.t(), String.t() | nil, map()) :: {:ok, result()} | {:error, error()}
Validate the ID-JAG assertion, claim its replay identity, and resolve the
local subject.
client_id is the already-authenticated client's identifier (the token
endpoint resolved it from client authentication); the assertion's client_id
claim MUST equal it. Returns {:ok, %{subject, scope_ceiling, claims}} or
{:error, t:error/0}.
@spec commit_replay_claim(AttestoPhoenix.Config.t(), pending_claim()) :: :ok | {:error, :replay}
Atomically claim a replay identity returned by prepare/3 before minting.
The configured replay callback must return exactly :ok or
{:error, :replay}. Any other result raises as an integration or storage
fault rather than being mislabeled as a replay.
@spec prepare(AttestoPhoenix.Config.t(), String.t() | nil, map()) :: {:ok, prepared_result()} | {:error, error()}
Validate an ID-JAG while deferring subject resolution and its atomic replay claim.
The token core uses this variant so sender binding, resource, scope, and host
policy can finish before invoking a potentially side-effecting subject
resolver or consuming the assertion. A caller MUST then call
resolve_subject/3 with :issuer_context, then pass :replay_claim to commit_replay_claim/2 before
minting or releasing an authorization result. Most callers should use
authorize/3, which performs both steps itself.
@spec prepare(AttestoPhoenix.Config.t(), String.t() | nil, map(), term()) :: {:ok, prepared_result()} | {:error, error()}
Prepare an assertion using the request client supplied to the issuer resolver.
prepare/3 supplies the client identifier when only that identifier is available.
@spec resolve_subject( AttestoPhoenix.Config.t(), Attesto.IdentityAssertion.claims(), term() ) :: {:ok, String.t()} | {:error, :subject_denied}
Resolve verified ID-JAG claims to a local principal subject.
Required when the feature is enabled (configuration validation enforces this), so
an unset callback is a configuration fault. The two-argument host callback
receives the verified claims and a map containing :issuer_context and the
verified :aud_tenant. The one-argument form receives only the claims.