Skip to content

Add a dashboard.mode setting: dashboard only (default), API only (headless), or both #3974

Open
0 of 3 issues completed

Description

@pithead-developer

What's the problem

There is no way to choose what Pithead serves. One aiohttp process behind Caddy serves the UI and every API on the same vhosts under one optional login; /metrics, /api/state and /static all go to the same upstream. The UI cannot be turned off, and the new external APIs (system information, host metrics, logs) would be exposed to anyone with a login with no way to keep them closed by default.

What it impacts

Everyone: the default should stay as it is, with the new external query APIs closed. Headless users who want only JSON/metrics/log APIs, and the first boot, container healthcheck, CLI and boot-health gate, which depend on the dashboard process.

Depends on #3872 / PR #3895 for /login, sessions and the MACHINE_ROUTES table. Related: #786 (appliance parity).

How I found it

A request to make dashboard-only the default mode. I read create_app in web/server.py (routes already gated by DASHBOARD_CONTROL_ENABLED return 404 when off, a precedent), generate_caddyfile, the config parse/validate/render path for dashboard.control.enabled (lib/pithead/27-defaults-and-config-validation.sh), the wizard server and PR #3895's machine credentials. DASHBOARD_CONTROL_ENABLED is an env constant read in create_app, so dashboard.mode needs the same config-to-env path. An open-issue search for headless, api-only and dashboard.mode found no duplicate; #3872 (login page), #3579 (settings editor) and #786 are related but not the same.

How important is it

Medium. New feature (2.1.0). The system-information (#3975), host-metrics (#3976) and live log (#3978) APIs depend on it for their off-by-default behavior; the "This box" view (#3977) works in every mode.

Acceptance criteria

  • Config key dashboard.mode with values dashboard (default), api, both. An invalid value fails config validation. Existing configs without the key behave as dashboard.
  • dashboard: UI works; the new system-information, host-metric and log APIs are not served (404). The existing /metrics and the other existing routes (including /api/miner-connection, /api/xvb-standby and /api/access) behave exactly as today, under their current auth. The UI's own internal calls keep working.
  • api: no web UI (/, /static, /ui-preview, /login return 404 in the app, not only in Caddy). The existing /metrics, /api/miner-connection, /api/xvb-standby and /api/access remain served as today. The container healthcheck (HEAD /api/state on the app's loopback port) and ./pithead status/doctor keep working. The boot-health gate goes through Caddy: /.pithead-boot-health is rewritten to /, so in api mode either the rewrite targets /api/state or / returns a minimal 200 body. The Add dashboard login sessions with admin and viewer roles #3895 boot-token path keeps working.
  • both: UI and external APIs served.
  • Auth for API clients: Add dashboard login sessions with admin and viewer roles #3895 gives fixed per-route machine accounts (metrics, standby; Bearer on /metrics only). This issue adds scoped credentials (state, metrics, logs, system) on top; the interactive login session is not required. Credential create, rotate and revoke are available without the UI (CLI or config). Every external API route rejects unauthenticated requests (401) and out-of-scope tokens (403).
  • Privacy: external APIs are served on the LAN listener only, never exposed beyond it by default; credentials and tokens are redacted in logs, API responses and describe-change output; the logs API redacts secrets and bounds response size and request rate.
  • Setup: the first-boot wizard is a separate app and still runs in api mode; a pre-seeded pithead-config.json or the CLI can set the mode; the wizard states what api mode means.
  • Switching is an apply-time config change: it appears in the describe-change preview, names the containers recreated (dashboard, caddy) and takes effect on apply, never live.
  • Safety: choosing api without the control channel or any machine credential is refused or loudly warned, since the appliance has no shell.
  • Tests: route table per mode, 401/403 auth cases, container healthcheck in api mode, Caddyfile rewrite for @boot_health (generate_caddyfile) in api mode, validation, describe-change text.

Possible solutions

  • Skip route registration in create_app per mode (as control does) versus a Caddy matcher only; Caddy alone leaves the app reachable on the loopback port. Either way generate_caddyfile changes for the boot-health rewrite.
  • Credential model: scoped bearer tokens versus basic credentials per route group.
  • Where the key lives: dashboard.mode versus separate dashboard.ui.enabled and dashboard.api.enabled.
  • Unknown: whether Add dashboard login sessions with admin and viewer roles #3895 lands first and how its MACHINE_ROUTES table should absorb new scopes.

Sub-issues

Sub-issues

0 of 3 Issues completed
Loading 3 sub-issues

Activity

  1. added this to the v2.1.0 milestone on Nov 10, 2026
  2. added
    enhancement
    dashboard
    security
    on Nov 10, 2026
  3. added
    tracker
    on Nov 26, 2026
  4. pithead-architect commented on Nov 26, 2026

    @pithead-architect

    A local session judged this too big for one local session (Too big for one local session: #3974 carries three distinct objectives — making dashboard.mode actually gate what is served (app routes + Caddy boot-health rewrite), the apply-time switch experience (describe-change row + lockout guard), and a scoped API-credential subsystem (401/403, CLI create/rot). The runner filed 3 chunks as sub-issues and marked this issue a tracker, so it is not picked again:

  5. pithead-architect commented on Nov 27, 2026

    @pithead-architect

    Release regroom (owner request, 2026-11-27): moved from v2.1.0 to v2.1.3. Headless-dashboard and system-info UI chain depends on the login work in 2.1.0; second UI chunk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dashboardenhancementsecuritytracker

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions