AttestoPhoenix.Plug.PutConfig (AttestoPhoenix v3.0.0)

Copy Markdown View Source

Loads the host's validated Attesto configuration into conn.private.

AttestoPhoenix controllers use two immutable configuration values:

  • %AttestoPhoenix.Config{} under :attesto_phoenix_config
  • the derived %Attesto.Config{} under :attesto_protocol_config

Mount this plug in the pipeline passed to AttestoPhoenix.Router.attesto_routes/1:

pipeline :attesto_phoenix_config do
  plug AttestoPhoenix.Plug.PutConfig, otp_app: :my_app
end

scope "/" do
  attesto_routes(pipeline: :attesto_phoenix_config)
end

The explicit :otp_app option is preferred. When it is omitted, the plug reads config :attesto_phoenix, otp_app: :my_app at request time. Existing correctly typed private values are preserved, which lets a host install a request-specific configuration earlier in the pipeline. A preinstalled protocol config must exactly match the value derived from that request's host config; otherwise the plug fails closed instead of advertising policy that the token endpoints do not enforce. A value of the wrong type also fails closed instead of being silently replaced. Library controllers and AttestoPhoenix.Plug.Authenticate bind the private configuration only while their bounded work executes; this plug does not retain tenant state in the process dictionary between pipeline and action dispatch.

Summary

Types

options()

@type options() :: %{otp_app: atom() | :from_application_env}