Skip to content

The agent that grows with you

fix(webapp): ignore a kept LAN sign-in registration in --status on a private Webapp

unsupportedpastels49c34e10967c
diff --git a/hermes_cli/webapp_launcher.py b/hermes_cli/webapp_launcher.py
index f5428019019..08ee365b1d1 100644
--- a/hermes_cli/webapp_launcher.py
+++ b/hermes_cli/webapp_launcher.py
@@ -206,11 +206,17 @@ def _plain_http_note(url: str) -> str | None:
def _browser_address(target: Path, settings, served_url: str) -> str:
"""Where a browser opens the Webapp the gateway serves at *served_url* (its loopback dial origin), as
- ``webapp-launch`` works it out behind sign-in: ``webapp.public_url`` when set, else the LAN address
- Web Access registered Nous sign-in for, else *served_url*. Read from *target*'s config now, not from
- when the gateway started."""
+ ``webapp-launch`` works it out: ``webapp.public_url`` when set, else behind sign-in the LAN address
+ Web Access registered Nous sign-in for, else *served_url* (a private Webapp's launch link). Read from
+ *target*'s config now, not from when the gateway started."""
+ from hermes_cli.web_server_boundary import public_hosts_engage_gate, public_url_hosts, should_require_auth
from hermes_cli.webapp_access import registered_lan_origin
- return settings.public_url or registered_lan_origin(target, urlsplit(served_url).port) or served_url
+ # The sign-in gate gateway.run_api.start_gateway_api engages on the Webapp's listener; without it
+ # webapp-launch hands out the loopback launch link and never reads the registration, which outlives
+ # a move back to a loopback bind.
+ gated = should_require_auth(settings.host) or public_hosts_engage_gate(public_url_hosts(settings.public_url))
+ lan = registered_lan_origin(target, urlsplit(served_url).port) if gated else None
+ return settings.public_url or lan or served_url
def _status(target: Path) -> int:
diff --git a/tests/hermes_cli/test_webapp_launcher.py b/tests/hermes_cli/test_webapp_launcher.py
index 5118ad19644..9583d6d62a1 100644
--- a/tests/hermes_cli/test_webapp_launcher.py
+++ b/tests/hermes_cli/test_webapp_launcher.py
@@ -481,6 +481,18 @@ def test_status_gets_no_plain_http_warning_when_browsers_open_a_secure_address(w
assert "plain http" not in capsys.readouterr().out.lower()
[email protected]("host", ["127.0.0.1", "localhost"])
+def test_status_of_a_private_webapp_ignores_a_lan_sign_in_registration_it_kept(world, capsys, host):
+ """Web Access keeps its LAN sign-in registration after webapp.host goes back to loopback. With no
+ sign-in gate, hermes webapp opens the loopback launch link, so --status does not warn."""
+ _home(world["root"], f"webapp:\n enabled: true\n host: {host}\n")
+ _register_lan_sign_in(world, "192.168.1.20")
+ assert launcher.cmd_webapp(_args(status=True)) == 0
+ out = capsys.readouterr().out
+ assert "Serving at http://127.0.0.1:9120" in out
+ assert "plain http" not in out.lower()
+
+
@pytest.mark.parametrize("url", ["http://127.0.0.1:9120/", "http://127.0.0.2:9120/", "http://localhost:9120/",
"http://hermes.localhost:9120/", "http://[::1]:9120/",
"https://hermes.example.ts.net/"])