AttestoPhoenix.DPoP.Adapter (AttestoPhoenix v2.7.0)

Copy Markdown View Source

Resolve the callback and option boundary between AttestoPhoenix.Config and Attesto.DPoP.

The adapter deliberately stops at option construction. It never verifies a proof and never records a replay identity. Callers choose whether :replay_check is included because token-endpoint sender constraints must defer that check until the grant has validated, while PAR and device authorization verify their proof inline.

Summary

Functions

Adapt the configured mTLS certificate extractor to the verifier's 1-arity callback form.

Resolve the canonical request URL callback used for DPoP htu.

Resolve the server-issued nonce validator, or nil when unused.

Resolve the fresh-nonce issuer, or nil when nonce checks are unused.

Build the DPoP/mTLS options consumed by Attesto.Plug.Authenticate.

Adapt the configured replay callback to the verifier's 2-arity form.

Types

verification_mode()

@type verification_mode() :: :inline | :deferred

Functions

cert_der(config)

@spec cert_der(AttestoPhoenix.Config.t()) :: (Plug.Conn.t() -> binary() | nil) | nil

Adapt the configured mTLS certificate extractor to the verifier's 1-arity callback form.

htu(config)

@spec htu(AttestoPhoenix.Config.t()) :: (Plug.Conn.t() -> String.t())

Resolve the canonical request URL callback used for DPoP htu.

nonce_check(config)

@spec nonce_check(AttestoPhoenix.Config.t()) ::
  (String.t() | nil -> :ok | {:error, :use_dpop_nonce}) | nil

Resolve the server-issued nonce validator, or nil when unused.

nonce_issue(config)

@spec nonce_issue(AttestoPhoenix.Config.t()) :: (-> String.t()) | nil

Resolve the fresh-nonce issuer, or nil when nonce checks are unused.

protected_resource_opts(config)

@spec protected_resource_opts(AttestoPhoenix.Config.t()) :: keyword()

Build the DPoP/mTLS options consumed by Attesto.Plug.Authenticate.

This is the protected-resource path: replay checking is disabled when DPoP is disabled, while htu, nonce, nonce issuance, and certificate extraction are resolved from the same Phoenix config used by the endpoint.

replay_check(config)

@spec replay_check(AttestoPhoenix.Config.t()) :: (String.t(), pos_integer() -> any())

Adapt the configured replay callback to the verifier's 2-arity form.

verification_opts(config, input, options \\ [])

@spec verification_opts(AttestoPhoenix.Config.t(), map(), keyword()) :: keyword()

Build the conn-free options for Attesto.DPoP.verify_proof/2.

:replay_check defaults to :inline, which preserves the behavior of proof binding at PAR and device authorization. Pass replay_check: :deferred for the token endpoint; that mode omits the callback and leaves the returned replay identity for the caller to commit after grant validation.

nonce_check: true adds the configured nonce callback. It is opt-in because not every DPoP proof path currently requires server-issued nonces. http_method_default preserves the device-authorization default for direct callers that do not populate the request method.