Commit Graph

3 Commits

Author SHA1 Message Date
rcourtman
0da95f2991 Stop Basic API clients issuing browser sessions
Every request authenticated with Basic credentials created a session,
persisted it and wrote a login audit event. The auth check runs twice on
a routed request, so one call took two of the user's ten session slots.
Anything polling with Basic credentials, such as a script or a dashboard
widget, kept signing its owner's browser out.

An API client's Basic credentials now authenticate one request and issue
nothing, as an API token does. Only Pulse's own web client, which marks
its API calls, still gets a session: a browser behind a proxy that
forwards Basic credentials relies on it, and without it pays for a
password check per call and loses its Settings pages.

A cookie reaching the Basic branch was rejected, and handlers read the
username from the cookie, so it is still retired. A password used only
over Basic must leave a trace, so the first call per organization, user
and address is audited, then once a day. Failures stay audited.
2026-11-05 20:58:35 +00:00
rcourtman
5719bd4b7b Stop routers when internal/api tests end
No Router built by the internal/api tests was ever freed. At the end of a run
all 1,358 were still reachable, with 26,000 goroutines and 2.86 GiB live, so
peak memory grew with every new test until the release correctness job ran out
of memory on its 7 GiB runner.

Most test sites never stopped their Router's workers. The few that did were
pinned anyway, because the setup-token cleanup worker in ConfigHandlers had no
way to stop and holds callbacks back into the Router. That worker now joins
the Router's shutdown, and package tests build Routers through newTestRouter,
which stops them with the test. Two new tests fail if a Router stays reachable
after shutdown or a package test calls NewRouter directly.

Default command policies now share one compiled pattern set. A private copy
cost 230 KiB and 1.4 ms per call and is now 2.2 KiB and 1.6 us. It accounted
for a quarter of the live test heap. In production each organization's AI
service holds one, so this also saves about 230 KiB per organization.

Measured on pulse-dev at 88c2a21f65 with the same go test -count=1 -p 1 run:
peak RSS of the largest child 6.41 GiB before, 2.44 GiB after. That largest
child is now the compiler: a cold test build alone peaks at 2.34 GiB and the
test binary alone at 1.48 GiB. All package tests pass. CPU time fell about 5%;
wall clock followed the host's load and is not comparable between these runs.

Contract-Neutral: Stops test Router workers and shares compiled policy patterns; no API, policy decision or storage change.
2026-11-05 11:18:30 +00:00
rcourtman
7c9d979237 Enforce tenant and browser-origin request boundaries
Apply the admitted organization's access policy after Basic authentication and require tenant management for configuration transfers. Require exact origin metadata for same-site proxy-auth browser writes.

Cover tenant reads, token minting, transfer side effects, trusted proxy scheme handling and session CSRF through the production router.
2026-11-05 01:50:19 +00:00