AttestoPhoenix.ProtectedResource (AttestoPhoenix v2.7.0)

Copy Markdown View Source

Shared protected-resource authentication for Phoenix endpoints.

This module owns the transport check, access-token verification wiring, and revoked-token check used by protected-resource controllers. Endpoint actions receive the verified claims only after this common work succeeds.

Summary

Functions

Return whether the access token identified by the claims is revoked.

Translate the Phoenix configuration into the core Attesto configuration.

Run the protected-resource verification skeleton.

Build the transport options for a protected-resource error response.

Return the challenge scheme for verified token claims.

Types

result()

@type result() :: {:ok, Plug.Conn.t(), map()} | {:halt, Plug.Conn.t()}

Functions

access_token_revoked?(config, arg2)

@spec access_token_revoked?(AttestoPhoenix.Config.t(), map()) :: boolean()

Return whether the access token identified by the claims is revoked.

attesto_config(config)

@spec attesto_config(AttestoPhoenix.Config.t()) :: Attesto.Config.t()

Translate the Phoenix configuration into the core Attesto configuration.

authenticate(conn, config, resource_metadata)

@spec authenticate(Plug.Conn.t(), AttestoPhoenix.Config.t(), String.t() | nil) ::
  result()

Run the protected-resource verification skeleton.

Returns {:ok, conn, claims} when endpoint-specific work may proceed, or {:halt, conn} when the request has already been answered.

authenticate_opts(config, resource_metadata)

@spec authenticate_opts(AttestoPhoenix.Config.t(), String.t() | nil) :: keyword()

Build the options consumed by Attesto.Plug.Authenticate.

error_opts(config, resource_metadata, extra)

@spec error_opts(AttestoPhoenix.Config.t(), String.t() | nil, keyword()) :: keyword()

Build the transport options for a protected-resource error response.

scheme_of(arg1)

@spec scheme_of(map()) :: :dpop | :bearer

Return the challenge scheme for verified token claims.