Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ the desired value is not presented as proof of what the still-running services u
| `dashboard.auth.password` | `""` _(off)_ | Optional password to open the dashboard. Turns on a Caddy [HTTP basic-auth](https://caddyserver.com/docs/caddyfile/directives/basic_auth) prompt in front of every page. `""` (default) = no login, anyone who can reach the dashboard sees it. Setup chooses username `admin` and generates a 32-character alphanumeric password, shown once at the final handoff. It asks no login question; disable login only by setting an empty password in Advanced configuration. The password is absent from status, doctor and support bundles; the empty reference value remains unchanged for upgraded and restored configs. Any 8–128-character string (no double-quotes) turns the prompt on. The plaintext lives only in your owner-only `config.json`; pithead bcrypt-hashes it with the pinned Caddy image and stores only the hash in `.env`, so the password itself is never persisted in rendered state. The hashing container disables runtime logging to keep its credential hash out of the system journal. Basic-auth credentials travel in cleartext over HTTP, so keep `dashboard.secure: true` (the default); pithead warns if you set a password with `secure: false`. See [Exposing the dashboard safely](#exposing-the-dashboard-safely). |
| `dashboard.onion.enabled` | `false` _(off)_ | Privacy-relevant, default off. `true` publishes the dashboard as a Tor v3 onion service so you can reach it remotely over Tor — no port-forward, no VPN, no public IP. It fronts the authenticated Caddy login on the internal bridge, never the LAN. pithead **fails closed**: if no `dashboard.auth.password` is set it generates a strong one (saved to `config.json`, login `admin`); a password you set yourself must be at least 16 characters. See [Remote access over Tor](#remote-access-over-tor-onion-service). |
| `dashboard.onion.client_auth` | `true` _(on)_ | Only applies when `dashboard.onion.enabled` is `true`. Keeps Tor v3 **client authorization** on: the onion does not respond at all without your client key, so the address can't be scanned or brute-forced — the password becomes a second factor behind it. pithead generates the keypair; get the client line from the dashboard header's **Show client key** button, or with `./pithead onion-client-key` on a machine you can log in to. Set to `false` for a deliberately password-only onion — but not alongside `dashboard.control.enabled: true`: `apply` refuses that pairing, since a root-capable config-mutation channel must not sit behind only a brute-forceable password on an anonymously-reachable address. With `dashboard.control.enabled` absent, a password-only onion keeps the config editor off instead. |
| `dashboard.mode` | `dashboard` | Which interfaces the dashboard serves. `dashboard` (the default) serves the web UI only. `api` and `both` also serve the log API (`/api/logs/<service>` and `/follow`, see [Dashboard › Log API](dashboard.md#log-api)); in `dashboard` mode those routes answer 404. Anything else fails `apply`. |
| `dashboard.mode` | `dashboard` | Which interfaces the dashboard serves. `dashboard` (the default) serves the web UI only. `api` and `both` also serve the log API (`/api/logs/<service>` and `/follow`, see [Dashboard › Log API](dashboard.md#log-api)); in `dashboard` mode those routes answer 404. Anything else fails `apply`. The apply preview shows the switch and the dashboard and caddy containers it recreates. `api` with `dashboard.control.enabled` off is refused on the appliance, which has no shell to undo it, and warns on a DIY install. |
| `dashboard.control.enabled` | on whenever a login exists; `false` without one | Security-relevant. `true` turns on the dashboard's **Configuration view**: edit `config.json` from the browser, preview the changes, and apply them. The dashboard container never runs `pithead` itself — it writes a typed change request into a spool directory and a root systemd unit on the host (`pithead-control`) validates and applies it (see [Dashboard › Configuration view](dashboard.md#configuration-view)). With the key **absent** the editor rides on the login, identically on DIY and the appliance: on whenever `dashboard.auth.password` is set — a machine you can log into is a machine you can configure from the browser — and an explicit value always wins. `apply` still fails closed twice on an explicit `true`: without a `dashboard.auth.password` it is a validation error, because this channel can change the payout wallet; on a published onion (`dashboard.onion.enabled`) with `dashboard.onion.client_auth: false` it is refused too, since a password alone is brute-forceable over Tor. When the key is absent, that onion pairing keeps the editor off, without an error. |
| `dashboard.timezone` | `auto` | Timezone for the dashboard's timestamps and charts. `auto` = the host machine's timezone (auto-detected, falling back to `Etc/UTC`); set an IANA name (e.g. `America/Chicago`) to override. |
| **Notifications** | | _Choose where operational messages and alerts are sent._ |
Expand Down
6 changes: 6 additions & 0 deletions lib/pithead/28-parse-and-validate-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,12 @@ parse_and_validate_config() {
*) error "dashboard.mode must be \"dashboard\", \"api\" or \"both\" (got \"$DASHBOARD_MODE\")." ;;
esac
DASHBOARD_CONTROL_ENABLED=$(normalize_bool "$(config_bool '.dashboard.control.enabled' "$(control_enabled_default)")")
if [ "$DASHBOARD_MODE" == "api" ] && [ "$DASHBOARD_CONTROL_ENABLED" != "true" ]; then
if is_appliance; then
error "dashboard.mode is \"api\" but dashboard.control.enabled is false. The appliance has no shell, so this leaves no way to change the configuration back. Set dashboard.control.enabled: true (it needs dashboard.auth.password) or keep dashboard.mode \"dashboard\" or \"both\", and re-run."
fi
warn "dashboard.mode is \"api\" and dashboard.control.enabled is false: nothing here can change the configuration back except editing $CONFIG_FILE by hand and re-running '$0 apply'. Enable dashboard.control.enabled or keep that file reachable."
fi
if [ "$DASHBOARD_CONTROL_ENABLED" == "true" ] && [ -z "$dash_pw" ]; then
error "dashboard.control.enabled is true but dashboard.auth.password is empty. Config editing from the dashboard can change the payout wallet and run '$0 apply' — it must sit behind a login. Set dashboard.auth.password and re-run."
fi
Expand Down
10 changes: 10 additions & 0 deletions lib/pithead/39-describe-change.sh
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,16 @@ describe_change() {
# carries the user-facing message. Emit no message so the preview shows one line, not two.
msg=""
;;
DASHBOARD_MODE)
local mode_effect
case "$new" in
api) mode_effect="the log API (/api/logs/<service>) is served" ;;
both) mode_effect="the log API (/api/logs/<service>) is served alongside the web dashboard" ;;
*) mode_effect="the log API routes answer 404 and the web dashboard is served" ;;
esac
[ "$new" == "api" ] && flag=CONFIRM
msg="Dashboard mode: ${old:-dashboard} → $new — $mode_effect; the dashboard container is recreated (caddy is not) and it takes effect on apply."
;;
DASHBOARD_CONTROL_ENABLED)
if [ "$new" == "true" ]; then
flag=DEST
Expand Down
39 changes: 39 additions & 0 deletions tests/stack/dashboard/test-onion-apply-password.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,42 @@ assert_eq "dashboard.mode both rendered" "$(law_env DASHBOARD_MODE)" "both"
law_apply ',"mode":"headless"'
assert_rc "invalid dashboard.mode rejected" "$LAW_RC" "1"
assert_contains "invalid dashboard.mode message" "$LAW_OUT" "dashboard.mode must be"

echo "== unit: dashboard.mode preview and api lockout guard (issue 4539) =="
mode_preview() { run_sourced "$SANDBOX" describe_change DASHBOARD_MODE "$1" "$2"; }
assert_contains "mode dashboard to api names the transition" "$(mode_preview dashboard api)" "Dashboard mode: dashboard → api"
assert_contains "mode dashboard to api names the recreated container" "$(mode_preview dashboard api)" "the dashboard container is recreated (caddy is not) and it takes effect on apply"
assert_contains "mode dashboard to both names the transition" "$(mode_preview dashboard both)" "Dashboard mode: dashboard → both"
assert_contains "mode dashboard to both names the recreated container" "$(mode_preview dashboard both)" "the dashboard container is recreated (caddy is not) and it takes effect on apply"
assert_contains "mode api to dashboard names the transition" "$(mode_preview api dashboard)" "Dashboard mode: api → dashboard"
assert_contains "mode api to dashboard names the recreated container" "$(mode_preview api dashboard)" "the dashboard container is recreated (caddy is not) and it takes effect on apply"
assert_contains "mode api to both names the transition" "$(mode_preview api both)" "Dashboard mode: api → both"
assert_contains "mode api to both names the recreated container" "$(mode_preview api both)" "the dashboard container is recreated (caddy is not) and it takes effect on apply"
assert_contains "mode both to dashboard names the transition" "$(mode_preview both dashboard)" "Dashboard mode: both → dashboard"
assert_contains "mode both to dashboard names the recreated container" "$(mode_preview both dashboard)" "the dashboard container is recreated (caddy is not) and it takes effect on apply"
assert_contains "mode both to api names the transition" "$(mode_preview both api)" "Dashboard mode: both → api"
assert_contains "mode both to api names the recreated container" "$(mode_preview both api)" "the dashboard container is recreated (caddy is not) and it takes effect on apply"
assert_contains "mode api is a CONFIRM row" "$(mode_preview dashboard api)" "CONFIRM"
assert_contains "mode api says the log API is served" "$(mode_preview dashboard api)" "the log API (/api/logs/<service>) is served"
assert_contains "mode dashboard says the log API answers 404" "$(mode_preview api dashboard)" "answer 404"
assert_contains "mode both serves both" "$(mode_preview dashboard both)" "alongside the web dashboard"

law_apply_pw() {
law_apply ",\"mode\":\"$1\",\"auth\":{\"username\":\"admin\",\"password\":\"correct horse battery\"}$2"
}
PITHEAD_APPLIANCE=1 law_apply ',"mode":"api"'
assert_rc "appliance api without control is refused" "$LAW_RC" "1"
assert_contains "appliance refusal names the control channel" "$LAW_OUT" "dashboard.control.enabled"
assert_contains "appliance refusal names the lockout" "$LAW_OUT" "no shell"
PITHEAD_APPLIANCE=0 law_apply ',"mode":"api"'
assert_rc "DIY api without control still applies" "$LAW_RC" "0"
assert_contains "DIY api without control warns of the lockout" "$LAW_OUT" "change the configuration back"
PITHEAD_APPLIANCE=1 law_apply_pw api ',"control":{"enabled":true}'
assert_rc "appliance api with control validates" "$LAW_RC" "0"
assert_not_contains "api with control does not warn" "$LAW_OUT" "change the configuration back"
PITHEAD_APPLIANCE=1 law_apply ',"mode":"dashboard"'
assert_rc "appliance mode dashboard without control validates" "$LAW_RC" "0"
assert_not_contains "mode dashboard does not warn" "$LAW_OUT" "change the configuration back"
PITHEAD_APPLIANCE=1 law_apply ',"mode":"both"'
assert_rc "appliance mode both without control validates" "$LAW_RC" "0"
assert_not_contains "mode both does not warn" "$LAW_OUT" "change the configuration back"
Loading