Files
pad/internal/server
xarmian 9c5f4d5165 fix(cli): construct auth login URL on CLI side to avoid 0.0.0.0 leak (TASK-839) (#311)
* fix(cli): construct auth login URL on CLI side to avoid 0.0.0.0 leak (TASK-839)

The server builds the CLI auth-approval URL from r.Host, which echoes
back whatever Host header the CLI sent. When the local pad server is
bound to a bind-all address (e.g. --host 0.0.0.0), the CLI's own config
points at that address, so the URL printed by `pad auth login` ends up
as http://0.0.0.0:7777/auth/cli/{code} — a bind address, not a usable
browser destination.

Construct the URL on the CLI instead, using cfg.BrowserURL() (which
already rewrites 0.0.0.0 / :: / empty to 127.0.0.1, and returns the
explicit URL verbatim for Remote/Cloud). The server-issued auth_url
field is now ignored; session_code is what we actually need and is
already returned separately.

Extracts a small cliAuthBrowserURL helper so the wiring is unit-testable
and adds regression coverage for IPv4 bind-all, IPv6 bind-all, empty
host, explicit loopback, explicit Remote URL, and trailing-slash trim.

* chore(lint): remove unused readBundleAsBytes test helper

golangci-lint v2.11.4 (CI) flags this as unused — it was added in the
import-bundle test scaffolding (TASK-885 / TASK-891 era) but no caller
ever picked it up. Removing it unblocks the lint gate on main.

Reviewable in isolation; pure deletion, no behavior change.
2026-04-29 22:03:27 -04:00
..