You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Warn at dashboard startup when the control-plane token is unset #187
The dashboard's control-plane token (HEADLESSCODE_DASHBOARD_TOKEN, src/dashboard/server.ts) is optional: unset = no auth at all on POST /api/session/*, POST /api/tool/execute, POST /api/checkpoints/restore, and settings writes. That is a deliberate local-first default (binds 127.0.0.1), but nothing tells the operator they are running unauthenticated — and downstream sidecar composes have shipped with the token set to "". SECURITY.md documents the risk; the runtime stays silent.
Architecture (independent solution)
Warn loudly, change no default:
At dashboard startup (startDashboardServer / dashboard CLI path), if no token is configured, print one stderr banner: control-plane routes are unauthenticated, bound to loopback only, and how to set HEADLESSCODE_DASHBOARD_TOKEN. Print once, not per request.
If a token is set, print a single line confirming gated routes (never print the token).
Keep bind address and gating logic untouched.
Scope / non-goals
No fail-closed change, no new auth system, no compose changes in other repos (documented as follow-up in the hardening-docs issue).
Acceptance
Dashboard without token: banner visible in startup output; session/tool routes still work locally.
Dashboard with token: no warning banner; unauthenticated POST still 401.
Tests (happy / sad / bad)
Happy: token set → no warning, 401 without header, 200 with header (existing server tests cover the latter two; add the log assertion).
Sad: token unset → server starts, warning emitted once.
Bad: empty-string env treated as unset (matching the compose "" failure mode).
Contributor notes
Good first issue. Find the dashboard CLI entry (headlesscode dashboard) and mirror its existing stderr idiom; don't add a logging dependency.
src/dashboard/server.ts (new exported warnControlPlaneAuth(): stderr banner when token unset/empty — names unauthenticated control-plane routes, 127.0.0.1-only binding, and the env var; single gated line when set, never prints the token; called once from startDashboardServer listen callback)
src/dashboard/tests/server.test.ts (5 new tests: warning content, gated-no-leak, empty-string-as-unset, startup-warns-but-serves, startup-gated line; shortened 5 pre-existing over-length labels to fit the 80-col rule)
Baseline (before)
Dashboard startup printed only [dashboard] listening on .... No operator signal that control-plane POSTs were unauthenticated; compose ships the token as "" silently.
Baseline (after)
No token: [dashboard] WARNING: no HEADLESSCODE_DASHBOARD_TOKEN set — control-plane routes (...) are unauthenticated. Bound to 127.0.0.1 only. Set HEADLESSCODE_DASHBOARD_TOKEN to gate them. on stderr, once, at startup; routes still serve locally (asserted 200/500 on /api/summary).
Token set: [dashboard] control-plane routes are gated by HEADLESSCODE_DASHBOARD_TOKEN, token never echoed (asserted).
Empty-string token: takes the warning path (cli.ts || undefined maps "" → unset; unit-tested at warnControlPlaneAuth({token: ""})).
Bind address and gating logic untouched; All 15 dashboard server tests passed (10 pre-existing + 5 new).
npx tsc --noEmit clean; new code adds zero standards violations (one 81-char import fixed in passing in the Fleet file).
Boot check
Live probe: startDashboardServer({port: 0}) → warning banner on stderr; with token: "sekret" → gated line. Full npm test: run-tests: all 341 file(s) passed.
Residual risk / notes
Warning goes to stderr via process.stderr.write (matches existing dashboard CLI idiom; no logging dependency). Tests that capture stderr restore the original write in finally. The banner prints on every startDashboardServer call, including test-spawned servers — by design (once per process in production; the CLI starts exactly one server).
Activity
w4ffl35 commentedon Dec 5, 2026
Issue 187 — Closing Report
Files changed
warnControlPlaneAuth(): stderr banner when token unset/empty — names unauthenticated control-plane routes, 127.0.0.1-only binding, and the env var; single gated line when set, never prints the token; called once fromstartDashboardServerlisten callback)Baseline (before)
Dashboard startup printed only
[dashboard] listening on .... No operator signal that control-plane POSTs were unauthenticated; compose ships the token as""silently.Baseline (after)
[dashboard] WARNING: no HEADLESSCODE_DASHBOARD_TOKEN set — control-plane routes (...) are unauthenticated. Bound to 127.0.0.1 only. Set HEADLESSCODE_DASHBOARD_TOKEN to gate them.on stderr, once, at startup; routes still serve locally (asserted 200/500 on/api/summary).[dashboard] control-plane routes are gated by HEADLESSCODE_DASHBOARD_TOKEN, token never echoed (asserted).|| undefinedmaps""→ unset; unit-tested atwarnControlPlaneAuth({token: ""})).All 15 dashboard server tests passed(10 pre-existing + 5 new).npx tsc --noEmitclean; new code adds zero standards violations (one 81-char import fixed in passing in the Fleet file).Boot check
Live probe:
startDashboardServer({port: 0})→ warning banner on stderr; withtoken: "sekret"→ gated line. Fullnpm test:run-tests: all 341 file(s) passed.Residual risk / notes
Warning goes to stderr via
process.stderr.write(matches existing dashboard CLI idiom; no logging dependency). Tests that capture stderr restore the original write infinally. The banner prints on everystartDashboardServercall, including test-spawned servers — by design (once per process in production; the CLI starts exactly one server).PR: #204
Merge pull request #204 from Capsize-Games/issues/w12-2026-12-05