revert(gateway): restore loopback auth setup

This commit is contained in:
Sebastian
2026-02-16 22:28:02 -05:00
parent b7cf28f407
commit 1486eb66fd
3 changed files with 57 additions and 75 deletions

View File

@@ -1,5 +1,7 @@
import fs from "node:fs";
import { intro as clackIntro, outro as clackOutro } from "@clack/prompts";
import fs from "node:fs";
import type { OpenClawConfig } from "../config/config.js";
import type { RuntimeEnv } from "../runtime.js";
import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js";
import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js";
import { loadModelCatalog } from "../agents/model-catalog.js";
@@ -9,14 +11,12 @@ import {
resolveHooksGmailModel,
} from "../agents/model-selection.js";
import { formatCliCommand } from "../cli/command-format.js";
import type { OpenClawConfig } from "../config/config.js";
import { CONFIG_PATH, readConfigFileSnapshot, writeConfigFile } from "../config/config.js";
import { logConfigUpdated } from "../config/logging.js";
import { resolveGatewayService } from "../daemon/service.js";
import { resolveGatewayAuth } from "../gateway/auth.js";
import { buildGatewayConnectionDetails } from "../gateway/call.js";
import { resolveOpenClawPackageRoot } from "../infra/openclaw-root.js";
import type { RuntimeEnv } from "../runtime.js";
import { defaultRuntime } from "../runtime.js";
import { note } from "../terminal/note.js";
import { stylePromptTitle } from "../terminal/prompt-style.js";
@@ -124,18 +124,14 @@ export async function doctorCommand(
note(gatewayDetails.remoteFallbackNote, "Gateway");
}
if (resolveMode(cfg) === "local") {
const gatewayBind = cfg.gateway?.bind ?? "loopback";
const tailscaleMode = cfg.gateway?.tailscale?.mode ?? "off";
const requireGatewayAuth = gatewayBind !== "loopback" || tailscaleMode !== "off";
const auth = resolveGatewayAuth({
authConfig: cfg.gateway?.auth,
tailscaleMode,
tailscaleMode: cfg.gateway?.tailscale?.mode ?? "off",
});
const needsToken =
requireGatewayAuth && auth.mode !== "password" && (auth.mode !== "token" || !auth.token);
const needsToken = auth.mode !== "password" && (auth.mode !== "token" || !auth.token);
if (needsToken) {
note(
"Gateway auth is off or missing a token. Token auth is recommended when the gateway is exposed beyond local loopback.",
"Gateway auth is off or missing a token. Token auth is now the recommended default (including loopback).",
"Gateway auth",
);
const shouldSetToken =