feat(cli): attach terminal clients to the selected Desktop [skip ci]
NAN-104 requires terminal chat and browser attachment without granting a client ownership of Desktop's gateway. Resolve bounded short-lived credentials over authenticated current-user IPC, pin both Desktop and gateway identities, and reject replacement instances or incompatible clients before any mutation. Reuse the existing TUI artifact resolver behind a narrow Desktop-only entrypoint, keep credentials out of argv/environment/files, and preserve Python-mode reconnect and gateway leases. Add protocol, real-gateway, and anonymous IPC regression coverage; matching native-host and Windows acceptance remain release gates.
This commit is contained in:
1 parent
b373a95f5c
commit
48e7c4f697
20 files changed
+797
-52
No files matched your search
@@ -511,6 +511,8 @@ class GatewayHTTPHandler:
|
||||
# Bootstrap
|
||||
if got == "/webui/bootstrap":
|
||||
return self._handle_bootstrap(connection, request)
|
||||
if got == "/webui/terminal":
|
||||
return self._handle_bootstrap(connection, request, terminal_probe=True)
|
||||
|
||||
# Settings routes (delegated)
|
||||
response = await self.settings_routes.dispatch(connection, request, got)
|
||||
@@ -601,7 +603,9 @@ class GatewayHTTPHandler:
|
||||
|
||||
# -- Bootstrap ----------------------------------------------------------
|
||||
|
||||
def _handle_bootstrap(self, connection: Any, request: Any) -> Response:
|
||||
def _handle_bootstrap(
|
||||
self, connection: Any, request: Any, *, terminal_probe: bool = False,
|
||||
) -> Response:
|
||||
secret = self.config.token_issue_secret.strip() or self.config.token.strip()
|
||||
is_local_browser = _is_local_browser_request(connection, request.headers)
|
||||
is_proxy_authenticated = _is_trusted_proxy_authenticated_request(
|
||||
@@ -616,6 +620,11 @@ class GatewayHTTPHandler:
|
||||
elif not is_local_browser:
|
||||
return _http_error(403, "bootstrap is localhost-only")
|
||||
|
||||
terminal = {"protocolVersion": 1, "gatewayId": self.tokens.instance_id}
|
||||
if terminal_probe:
|
||||
# Capability probing does not allocate credentials or acquire client leases.
|
||||
return _http_json_response(terminal, extra_headers=_NO_STORE_HEADERS)
|
||||
|
||||
if is_proxy_authenticated:
|
||||
payload = {
|
||||
"ws_path": _normalize_config_path(self.config.path),
|
||||
@@ -651,6 +660,7 @@ class GatewayHTTPHandler:
|
||||
expected_path = _normalize_config_path(self.config.path)
|
||||
payload = {
|
||||
"token": token,
|
||||
"terminal": terminal,
|
||||
"ws_path": expected_path,
|
||||
"ws_url": ws_url,
|
||||
"expires_in": self.config.token_ttl_s,
|
||||
|
||||
Reference in new issue
Block a user