Countersign.Router (Countersign v0.1.0)

Copy Markdown View Source

Mounts the signer's link pages in a host's Phoenix router.

import Countersign.Router

scope "/" do
  pipe_through :signing
  countersign_routes "/sign", MyApp.Signing
end

config_module is a module with config/0 answering the host's Countersign.Config. The routes are:

The last three are behind Countersign.Web.Admit, which needs the session's verified code. The two POST routes carry the code in their body and are declared with log: false, so no host request-logs them. The token is in every path: keep these paths out of the host's request log as well, and send Referrer-Policy: no-referrer and Cache-Control: no-store from the pipeline. The host's LiveView socket must offer the :peer_data and :user_agent connect info, which the signature records. Behind a proxy the peer is the proxy: a host there derives the client IP in its own plug, keeps it in the session and names that key in the config's :client_ip_session_key, and the signature records it instead. A router mounts the signing page once: a second countersign_routes in the same router repeats the :countersign live_session.

path must equal the config's :sign_path, which builds the links and the page's redirects.

Summary

Functions

Declares the link routes under path for the config config_module.config().

Functions

countersign_routes(path, config_module)

(macro)

Declares the link routes under path for the config config_module.config().