ADR 0010: Embed an authenticated temporary UI in kasim
Status: Accepted; amended 2026-09-04 to allow explicit listen hosts
kasim ui is a temporary, read-only view of one resolved Simulation Target, not a persistent management service. The released kasim binary embeds standards-based HTML, CSS, and JavaScript assets and listens on 127.0.0.1 by default. An operator may explicitly select another listen host for a short-lived network-accessible session. The UI does not require a Node.js runtime, an external asset directory, another process, a Helm component, or a persistent deployment.
Every launch generates a high-entropy ephemeral capability token. The printed and optional browser-open URL carries it in the fragment so it is not sent in HTTP requests, logs, or referrers; the frontend supplies it as a bearer credential to every data request. Static assets reveal no cluster data. The server validates the selected Host and port; a wildcard listener accepts only an IP-literal Host on that port, which allows a reachable interface address without accepting arbitrary DNS Host values. The server omits permissive CORS, rejects non-GET/HEAD methods, sets a strict Content Security Policy and same-origin framing/resource headers, disables data caching, and exposes no mutation route. The browser JSON and streaming transport are versioned implementation details of the same kasim process, not a supported remote public interface.
The command follows standard client-go/kubectl kubeconfig loading rules and current-context when target flags are absent. --kubeconfig and --context independently override those defaults, and supplying both preserves exact-target selection. The resolved context and client configuration are frozen before the listener opens; this exception applies only to the read-only UI, while lifecycle commands retain mandatory explicit target flags. The command defaults to 127.0.0.1:8080 and supports --host, --port, and --open. A non-loopback listener prints a warning because its HTTP transport is unencrypted and its capability URL grants read access to the resolved inventory. A bind conflict or failed target establishment returns a stable startup diagnostic and closes the listener. Browser-open failure is a warning because the printed URL remains usable. SIGINT and SIGTERM cancel inventory synchronization, stop accepting requests, and perform a bounded graceful shutdown. Ordinary source permission failures or unsupported optional APIs do not stop the server; the page opens in partial or diagnostics-only mode.
Considered options
- An unauthenticated localhost API was rejected because other local origins and DNS-rebinding-style requests should not receive cluster metadata merely because the listener is on loopback.
- Cookies and a login flow were rejected because there is no remote user or persistent server; an in-memory capability is smaller and avoids CSRF state.
- SSE with a query-string token was rejected because the credential would appear in request URLs. The implementation may use authenticated fetch streaming with polling fallback.
- A persistent Helm-deployed dashboard remains rejected because it would require a different authentication, authorization, lifecycle, threat, and support model. Explicit
--hostis limited to the same temporary process and capability-token contract; operators remain responsible for trusted transport and network policy beyond loopback.
