From 3b67b1fe42317602dc9180fd7847da4ed3d7137d Mon Sep 17 00:00:00 2001
From: Ilker Manap
Date: Wed, 16 Sep 2026 16:57:58 +0200
Subject: [PATCH] Stop the dashboard linking to pages that are not where it is
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Clicking "metrics" on the web dashboard answered "no api key was provided".
The page is served twice and its navigation assumed one of them. Metrics,
pprof and the management API exist on the admin listener; account
administration, the profile and the chat exist on the client-facing port. The
nav offered the first set in both places, so on the public port those links
fell through to the API-key middleware — which is a far more confusing way to
say "that is not here" than a 404 would have been.
Each page now offers what is actually reachable from it, and the public one
says where the rest lives rather than pretending it does not exist, including
why that port is not exposed: pprof can dump the process heap, and the heap
holds every API key in plaintext.
Co-Authored-By: Claude Opus 5 (1M context)
---
internal/cli/server.go | 2 +-
internal/router/handlers.go | 2 +-
internal/web/dashboard.go | 26 +++++++++-----
internal/web/templates/dashboard.html | 15 +++++++-
internal/web/web_test.go | 51 +++++++++++++++++++++++----
5 files changed, 78 insertions(+), 18 deletions(-)
diff --git a/internal/cli/server.go b/internal/cli/server.go
index 51c1c8a8..3210be1f 100644
--- a/internal/cli/server.go
+++ b/internal/cli/server.go
@@ -127,7 +127,7 @@ func newServerCmd() *cobra.Command {
usage = st
}
adminMux.HandleFunc("GET /", web.Dashboard(
- api, usage, version.Version, 5*time.Second, log))
+ api, usage, version.Version, 5*time.Second, true, log))
adminMux.Handle("GET /_static/", web.Static())
// The same page on the client-facing port at /admin, behind a
diff --git a/internal/router/handlers.go b/internal/router/handlers.go
index d70f7658..31db5c9a 100644
--- a/internal/router/handlers.go
+++ b/internal/router/handlers.go
@@ -115,7 +115,7 @@ func (r *Router) Handler() http.Handler {
// the admin listener — which also carries pprof, and pprof can dump
// the heap that holds every API key in plaintext.
mux.HandleFunc("GET /admin", pages.AdminPage(web.Dashboard(
- r.clusterView, r.clusterUsage, version.Version, 5*time.Second, r.log)))
+ r.clusterView, r.clusterUsage, version.Version, 5*time.Second, false, r.log)))
pages.RegisterAdminUsers(mux, r.store)
}
}
diff --git a/internal/web/dashboard.go b/internal/web/dashboard.go
index a25fb089..46aac1d5 100644
--- a/internal/web/dashboard.go
+++ b/internal/web/dashboard.go
@@ -32,9 +32,18 @@ type DashboardData struct {
TotalReplicas int
AuthEnabled bool
- RefreshSec int
- Version string
- Now string
+ // OnAdminListener decides which links the page offers.
+ //
+ // The same page is served twice, and the two have different neighbours:
+ // metrics, pprof and the management API exist only on the admin listener,
+ // while account administration and the profile exist only on the
+ // client-facing one. A nav that assumes one of them sends every visitor to
+ // the other into a 404 — or, on the public port, into "no api key was
+ // provided", which is a far more confusing way to say the same thing.
+ OnAdminListener bool
+ RefreshSec int
+ Version string
+ Now string
}
// Source is what the dashboard reads. An interface so the page can be rendered
@@ -65,7 +74,7 @@ type UsageSource interface {
// where it needs a shell on the machine rather than a browser session this
// project has no way to authenticate.
func Dashboard(src Source, usage UsageSource, version string, refresh time.Duration,
- log *slog.Logger,
+ onAdminListener bool, log *slog.Logger,
) http.HandlerFunc {
if log == nil {
log = slog.Default()
@@ -75,10 +84,11 @@ func Dashboard(src Source, usage UsageSource, version string, refresh time.Durat
}
return func(w http.ResponseWriter, r *http.Request) {
d := DashboardData{
- RefreshSec: int(refresh.Seconds()),
- Version: version,
- Now: time.Now().UTC().Format(time.RFC3339),
- AuthEnabled: usage != nil,
+ OnAdminListener: onAdminListener,
+ RefreshSec: int(refresh.Seconds()),
+ Version: version,
+ Now: time.Now().UTC().Format(time.RFC3339),
+ AuthEnabled: usage != nil,
}
if src != nil {
d.Nodes = src.Nodes()
diff --git a/internal/web/templates/dashboard.html b/internal/web/templates/dashboard.html
index 4f4a5ab8..568dcb7d 100644
--- a/internal/web/templates/dashboard.html
+++ b/internal/web/templates/dashboard.html
@@ -8,10 +8,15 @@
@@ -100,6 +105,14 @@ written in batches, so the last few seconds may be missing.
Authentication is off, so there is no identity to account against.
{{end}}
+{{if not .OnAdminListener}}
+
Metrics, pprof and the management API are on the admin listener,
+which is bound to loopback and not reachable from here. pprof can dump the
+process heap, where API keys sit in plaintext, which is why that port is not
+exposed:
+ssh -L 9090:127.0.0.1:9090 <control-plane>