mcl-bookclub#12 (Phoenix twin): Host allow-list, Origin on POST, and the console socket's Origin #19
Loading…
Reference in a new issue
No description provided.
Delete branch "mercurius/12-host-allow-list"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Purpose (fix): a web page outside the LAN cannot send a command to the Phoenix admin, read from it, or drive its console, by rebinding its own name to the box's LAN address. This is the Phoenix twin of macula-services/mcl-bookclub PR #13.
Stacked on PR #18 (base
mercurius/4-pr5b-service), so it reuses PR 18's test helpers in the same file, as the Erlang twin does. Land after #18.Threat model and Done-when: macula-services/mcl-bookclub#12 (comment)
42ad091red first: on #18's tip, 5 tests fail (a rebound Host on POST, on GET, on the console and on assets; a listed name; a foreign Origin; a rebound page's LiveView socket gets 101). The IP/localhost/own-Origin cases pass.0abbab9MclBookclubPhoenixWeb.AllowedHost, first plug in the endpoint: the Host must be an IP literal, localhost or a name inMCL_ADMIN_HOSTS, otherwise 403host_not_allowed. A POST's Origin must be its own, otherwise 403origin_not_allowed. The LiveView socket is dispatched before plugs, socheck_origin(it wasfalse) now callsAllowedHost.origin_allowed?/1.test_helper.exslistswww.example.com, the Hostbuild_conn/0sends. Docs: README, architecture, Containerfile, CHANGELOG, and the #9 plug/router comments.Local (OTP 28.4.3, Elixir 1.18.4): format, compile --warnings-as-errors, credo --strict, 266 tests 0 failures, dialyzer clean. Mutant: with
origin_allowed?/1always true, the socket test fails (1 of 20).Refs macula-services/mcl-bookclub#12
Landed by fast-forward: main is
ee4d318368(from4350b75a). This repository does not allow the manually-merged style, so the PR is closed by hand.Pull request closed