/** * Shared auth check for every /dashboard* page (dashboard.ts + the * dashboard-*-html.ts siblings). Previously each file duplicated its own * bearerOk/cookieOk check "by design" (independent reviewability); adding a * second auth mode (dev no-auth, see below) to N hand-copied checks would * have let them drift, so this is now the one place that decides. * * Behavior: * 1. `auth.devNoAuth` active (config true AND loopback bind — computed * once in app.ts and threaded down to every dashboard route factory) * AND the request's Host header resolves to loopback * (`isLoopbackHostHeader`) => access granted, no token/cookie required * (subject to the Origin check below). * 2. `devNoAuth` active but Host does NOT resolve to loopback => 403. This * is the same DNS-rebinding defense app.ts's preHandler applies to API * routes (see network.ts's isLoopbackHostHeader doc comment) — without * it, a page a rebinding attack served under an attacker-controlled * hostname could read memory titles/metrics off the dashboard. * 3. `devNoAuth` active, Host is loopback, but an `Origin` header is * present and does NOT resolve to loopback => 403. A `