fix(dashboard): read SPA gating from the mounted app, not the module global - #71150
fix(dashboard): read SPA gating from the mounted app, not the module global#71150joelbrilliant wants to merge 1 commit into
Conversation
|
Thanks for the focused fix. Current main confirms the premise: The proposed Automated hermes-sweeper review. |
…global Every route in mount_spa(application) registers on the "application" parameter, but _serve_index decided the auth scheme from the module-level "app". Production calls mount_spa(app), so the two are the same object and behaviour is unchanged - but the SPA's auth scheme was being read from an object it was not mounted on. That matters because this flag decides whether the long-lived _SESSION_TOKEN is injected into index.html. Gated mode withholds it and the browser uses a cookie session instead; ungated mode injects it. A second mount (embedded host, test harness, any future sub-app) inherits the global's gating, so a gated app whose global is ungated would emit the very token gated mode exists to withhold. Tests pin both directions with the app and the global deliberately disagreeing: a gated app stays gated when the global is not, and an ungated app stays ungated when the global is. 508 passed in test_web_server.py. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
7ee4818 to
4e3a1d8
Compare
|
Thanks for confirming the mounted-app seam. I’ve rebased the branch onto current main as |
The problem
Every route in
mount_spa(application)registers on theapplicationparameter, but_serve_indexdecided the auth scheme from the module-levelapp:Production calls
mount_spa(app), so the two are the same object and today's behaviour is correct. But the SPA's auth scheme was being read from an object it was not mounted on.Why it matters
That flag decides whether the long-lived
_SESSION_TOKENis injected intoindex.html. Gated mode withholds it and the browser authenticates with a cookie session instead; ungated mode injects it — which is exactly the property that makes it safe to put the dashboard behind a reverse proxy.So a second mount (an embedded host, a test harness, any future sub-app) inherits the global's gating rather than its own. A gated app whose global is ungated would emit the very token gated mode exists to withhold.
Found while writing a test for that no-token invariant: setting
auth_requiredon the app under test had no effect, because the code was reading a different app.The fix
Read from
application— the app the SPA was actually mounted on.One line. Behaviour-identical in production (single caller,
mount_spa(app)), correct for every other mount.Tests
Two, with the app and the global deliberately disagreeing, which is the only way to tell the seams apart:
Both fail before the change and pass after.
tests/hermes_cli/test_web_server.py: 508 passed.