Skip to content

The agent that grows with you

fix(dashboard): native-ticket callers clear route-local token checks

teknium131753a161189
diff --git a/hermes_cli/web_server.py b/hermes_cli/web_server.py
index 9003f981f21..b13a19b7aa2 100644
--- a/hermes_cli/web_server.py
+++ b/hermes_cli/web_server.py
@@ -289,7 +289,12 @@ def _require_token(request: Request) -> None:
``gated_auth_middleware`` already 401'd anything without a verified
``request.state.session`` — requiring the absent token here would make every
``_require_token`` endpoint unreachable behind the gate, so defer to it.
+ A verified native owner (``authenticate_native_http``) is the same-user
+ principal the outer seams already accepted; local Desktop runs with no
+ static token, so that principal must satisfy route-local policy too.
"""
+ if getattr(request.state, "native_http_principal", None):
+ return
if getattr(request.app.state, "auth_required", False):
ok = getattr(request.state, "session", None) is not None
else:
diff --git a/tests/gateway/test_native_http_auth.py b/tests/gateway/test_native_http_auth.py
index bf0fffba4b5..e142a7fc34e 100644
--- a/tests/gateway/test_native_http_auth.py
+++ b/tests/gateway/test_native_http_auth.py
@@ -233,3 +233,20 @@ async def test_native_http_preserves_gated_auth_and_actual_socket_boundary(tmp_p
clear_providers()
print(json.dumps({'normal_oauth_bearer_cookie': 'passed',
'native_gated_auth_raw_peer_readiness': 'passed'}))
+
+
+def test_native_http_principal_satisfies_route_local_token_policy(tmp_path):
+ """Routes that call ``_require_token`` honor the verified native owner (F16).
+
+ Local Desktop runs with authMode=native and no static token; the outer seam
+ admitted the ticket, so the route-local check must not 401 the same request.
+ """
+ with daemon(tmp_path) as (home, descriptor), httpx.Client(
+ base_url=descriptor['api_origin'], trust_env=False, timeout=30) as client:
+ hub = client.get('/api/dashboard/plugins/hub', headers=headers(ticket(home, descriptor)))
+ assert hub.status_code == 200, hub.text
+ oauth = client.delete('/api/providers/oauth/__not_a_real_provider__',
+ headers=headers(ticket(home, descriptor)))
+ assert oauth.status_code == 400, oauth.text
+ assert client.delete('/api/providers/oauth/__not_a_real_provider__').status_code == 401