Skip to content

Commit 44e8b6f

Browse files
steipeteampagent
andauthored
fix(onboarding): stop printing gateway token URLs (#124687)
* fix(onboarding): stop printing gateway token URLs Amp-Thread-ID: https://ampcode.com/threads/T-01a00ae0-190d-718b-8a76-b75f3e8d1fae * fix(onboarding): finish token-free handoff cleanup --------- Co-authored-by: Amp <[email protected]>
1 parent 39dc653 commit 44e8b6f

9 files changed

Lines changed: 22 additions & 84 deletions

File tree

‎docs/cli/onboard.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ Skills: `--node-manager <npm|pnpm|bun>` (default `npm`), `--skip-skills`.
360360

361361
UI and hook setup: `--skip-ui` (skip Control UI/TUI prompts), `--skip-hooks` (skip webhook/hook setup), `--skip-channels`, `--skip-search`.
362362

363-
Output: `--suppress-gateway-token-output` suppresses token-bearing Gateway/UI output (token hints, auto-login URL with embedded token, and automatic Control UI launch) - useful in shared terminals and CI.
363+
Output: `--suppress-gateway-token-output` disables the automatic Control UI handoff in guided onboarding. Classic onboarding never prints reusable Gateway token values or tokenized URLs; it still prints safe recovery commands.
364364

365365
<Note>
366366
`--json` does not imply non-interactive mode in guided or classic onboarding.

‎src/cli/program/register.onboard.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export function registerOnboardCommand(program: Command): void {
244244
.option("--skip-search", "Skip search provider setup")
245245
.option("--skip-health", "Skip health check")
246246
.option("--skip-ui", "Skip Control UI/TUI prompts")
247-
.option("--suppress-gateway-token-output", "Suppress token-bearing Gateway/UI output")
247+
.option("--suppress-gateway-token-output", "Disable the guided Control UI handoff")
248248
.option("--skip-hooks", "Skip hook setup")
249249
.option("--node-manager <name>", "Node manager for skills: npm|pnpm|bun")
250250
.option("--import-from <provider>", "Migration provider to run during onboarding")

‎src/cli/program/register.setup.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export function registerSetupCommand(program: Command): void {
252252
.option("--skip-search", "Skip search provider setup")
253253
.option("--skip-health", "Skip health check")
254254
.option("--skip-ui", "Skip Control UI/TUI launch")
255-
.option("--suppress-gateway-token-output", "Suppress token-bearing Gateway/UI output")
255+
.option("--suppress-gateway-token-output", "Disable the guided Control UI handoff")
256256
.option("--skip-hooks", "Accepted for onboard compatibility; hooks setup is skipped")
257257
.option("--node-manager <name>", "Node manager for skills: npm|pnpm|bun")
258258
.option("--import-from <provider>", "Migration provider to run during onboarding")

‎src/commands/onboard-helpers.ts‎

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { resolveAgentModelPrimaryValue } from "../config/model-input.js";
2020
import { resolveConfigPath, resolveStateDir } from "../config/paths.js";
2121
import { resolveSessionTranscriptsDirForAgent } from "../config/sessions/paths.js";
2222
import type { OptionalBootstrapFileName } from "../config/types.agent-defaults.js";
23-
import type { GatewayAuthMode } from "../config/types.gateway.js";
2423
import type { OpenClawConfig } from "../config/types.openclaw.js";
2524
import {
2625
resolveAdvertisedControlUiLinks,
@@ -51,18 +50,6 @@ export { detectBinary };
5150
export { detectBrowserOpenSupport, openUrl, resolveBrowserOpenCommand };
5251
export { resolveAdvertisedControlUiLinks, resolveControlUiLinks, resolveLocalControlUiProbeLinks };
5352

54-
/** Builds the token-authenticated Control UI URL shown by onboarding surfaces. */
55-
export function buildOnboardingControlUiUrl(params: {
56-
httpUrl: string;
57-
authMode?: GatewayAuthMode;
58-
token?: string;
59-
suppressTokenOutput?: boolean;
60-
}): string {
61-
return params.authMode === "token" && params.token && !params.suppressTokenOutput
62-
? `${params.httpUrl}#token=${encodeURIComponent(params.token)}`
63-
: params.httpUrl;
64-
}
65-
6653
/** Handles Clack cancellation by exiting through the runtime. */
6754
export function guardCancel<T>(value: T | symbol, runtime: RuntimeEnv, exitCode = 0): T {
6855
if (isCancel(value)) {
@@ -205,24 +192,16 @@ export function applyWizardMetadata(
205192
}
206193

207194
/** Formats the no-GUI SSH tunnel hint for opening the Control UI remotely. */
208-
export function formatControlUiSshHint(params: {
209-
port: number;
210-
basePath?: string;
211-
token?: string;
212-
}): string {
195+
export function formatControlUiSshHint(params: { port: number; basePath?: string }): string {
213196
const basePath = normalizeControlUiBasePath(params.basePath);
214197
const uiPath = basePath ? `${basePath}/` : "/";
215198
const localUrl = `http://localhost:${params.port}${uiPath}`;
216-
const authedUrl = params.token
217-
? `${localUrl}#token=${encodeURIComponent(params.token)}`
218-
: undefined;
219199
const sshTarget = resolveSshTargetHint();
220200
return [
221201
"No GUI detected. Open from your computer:",
222202
`ssh -N -L ${params.port}:127.0.0.1:${params.port} ${sshTarget}`,
223203
"Then open:",
224204
localUrl,
225-
authedUrl,
226205
"BYOH note: lan, tailnet, and custom bind are currently IPv4-only.",
227206
"If your host is IPv6-only, use an IPv4 sidecar or proxy in front of the Gateway.",
228207
"Docs:",

‎src/wizard/i18n/locales/en.ts‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,14 +1104,9 @@ export const en = {
11041104
controlUiTitle: "Control UI",
11051105
controlUiDocs: "Docs: https://docs.openclaw.ai/web/control-ui",
11061106
dashboardCopyPaste: "Copy/paste this URL in a browser on this machine to control OpenClaw.",
1107-
dashboardLinkWithToken: "Dashboard link (with token): {url}",
11081107
dashboardOpened: "Opened in your browser. Keep that tab to control OpenClaw.",
11091108
dashboardOpenAnytime: "Open the dashboard anytime: {command}",
11101109
dashboardReady: "Dashboard ready",
1111-
dashboardTokenMemory:
1112-
"Web UI keeps dashboard URL tokens in memory for the current tab and strips them from the URL after load.",
1113-
dashboardTokenPrompt:
1114-
"If prompted: paste the token into Control UI settings (or use the tokenized dashboard URL).",
11151110
dashboardWhenReady: "When you're ready: {command}",
11161111
daemonRuntime: "Gateway service runtime",
11171112
daemonRuntimeNode: "Node (recommended)",
@@ -1214,7 +1209,6 @@ export const en = {
12141209
webSearchUnavailableAction:
12151210
"web_search will not work until the provider is re-enabled or a different provider is selected.",
12161211
webUiUrl: "Web UI: {url}",
1217-
webUiWithTokenUrl: "Web UI (with token): {url}",
12181212
whatNow: 'What now: https://openclaw.ai/showcase ("What People Are Building").',
12191213
whatNowTitle: "What now",
12201214
workspaceBackupTitle: "Workspace backup",

‎src/wizard/i18n/locales/zh-CN.ts‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,14 +1067,9 @@ export const zh_CN = {
10671067
controlUiTitle: "Control UI",
10681068
controlUiDocs: "文档:https://docs.openclaw.ai/web/control-ui",
10691069
dashboardCopyPaste: "在本机浏览器中复制/粘贴这个 URL 来控制 OpenClaw。",
1070-
dashboardLinkWithToken: "Dashboard 链接(含令牌):{url}",
10711070
dashboardOpened: "已在浏览器中打开。保留该标签页以控制 OpenClaw。",
10721071
dashboardOpenAnytime: "随时打开 dashboard:{command}",
10731072
dashboardReady: "Dashboard 已就绪",
1074-
dashboardTokenMemory:
1075-
"Web UI 会把 dashboard URL 中的令牌保存在当前标签页内存中,并在加载后从 URL 中移除。",
1076-
dashboardTokenPrompt:
1077-
"如果被提示:把令牌粘贴到 Control UI 设置中(或使用带令牌的 dashboard URL)。",
10781073
dashboardWhenReady: "准备好后运行:{command}",
10791074
daemonRuntime: "Gateway 服务运行时",
10801075
daemonRuntimeNode: "Node(推荐)",
@@ -1170,7 +1165,6 @@ export const zh_CN = {
11701165
webSearchUnavailableAction:
11711166
"重新启用该 provider 或选择其他 provider 前,web_search 无法工作。",
11721167
webUiUrl: "Web UI:{url}",
1173-
webUiWithTokenUrl: "Web UI(含令牌):{url}",
11741168
whatNow: '下一步:https://openclaw.ai/showcase("What People Are Building")。',
11751169
whatNowTitle: "下一步",
11761170
workspaceBackupTitle: "工作区备份",

‎src/wizard/i18n/locales/zh-TW.ts‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,14 +1068,9 @@ export const zh_TW = {
10681068
controlUiTitle: "Control UI",
10691069
controlUiDocs: "文件:https://docs.openclaw.ai/web/control-ui",
10701070
dashboardCopyPaste: "在本機瀏覽器中複製/貼上這個 URL 來控制 OpenClaw。",
1071-
dashboardLinkWithToken: "Dashboard 連結(含權杖):{url}",
10721071
dashboardOpened: "已在瀏覽器中開啟。保留該分頁以控制 OpenClaw。",
10731072
dashboardOpenAnytime: "隨時開啟 dashboard:{command}",
10741073
dashboardReady: "Dashboard 已就緒",
1075-
dashboardTokenMemory:
1076-
"Web UI 會把 dashboard URL 中的權杖保存在目前分頁記憶體中,並在載入後從 URL 中移除。",
1077-
dashboardTokenPrompt:
1078-
"如果被提示:把權杖貼到 Control UI 設定中(或使用帶權杖的 dashboard URL)。",
10791074
dashboardWhenReady: "準備好後執行:{command}",
10801075
daemonRuntime: "Gateway 服務執行環境",
10811076
daemonRuntimeNode: "Node(建議)",
@@ -1171,7 +1166,6 @@ export const zh_TW = {
11711166
webSearchUnavailableAction:
11721167
"重新啟用該 provider 或選擇其他 provider 前,web_search 無法運作。",
11731168
webUiUrl: "Web UI:{url}",
1174-
webUiWithTokenUrl: "Web UI(含權杖):{url}",
11751169
whatNow: '下一步:https://openclaw.ai/showcase("What People Are Building")。',
11761170
whatNowTitle: "下一步",
11771171
workspaceBackupTitle: "工作區備份",

‎src/wizard/setup.finalize.test.ts‎

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -139,21 +139,8 @@ const inspectWindowsGatewayFirewall = vi.hoisted(() =>
139139
);
140140

141141
vi.mock("../commands/onboard-helpers.js", () => ({
142-
buildOnboardingControlUiUrl: (params: {
143-
httpUrl: string;
144-
authMode?: "token" | "password";
145-
token?: string;
146-
suppressTokenOutput?: boolean;
147-
}) =>
148-
params.authMode === "token" && params.token && !params.suppressTokenOutput
149-
? `${params.httpUrl}#token=${encodeURIComponent(params.token)}`
150-
: params.httpUrl,
151142
probeGatewayReachable,
152143
resolveAdvertisedControlUiLinks,
153-
resolveControlUiLinks: vi.fn(() => ({
154-
httpUrl: "http://127.0.0.1:18789",
155-
wsUrl: "ws://127.0.0.1:18789",
156-
})),
157144
resolveLocalControlUiProbeLinks,
158145
waitForGatewayReachable,
159146
}));
@@ -1548,8 +1535,12 @@ describe("finalizeSetupWizard", () => {
15481535
expect(gatewayServiceInstall).not.toHaveBeenCalled();
15491536
});
15501537

1551-
it("suppresses token-bearing onboarding output when requested", async () => {
1538+
it("never prints the reusable Gateway token during classic onboarding", async () => {
15521539
const prompter = createLaterPrompter();
1540+
const runtimeLog = vi.fn();
1541+
const runtimeError = vi.fn();
1542+
const runtime = { log: runtimeLog, error: runtimeError, exit: vi.fn() };
1543+
probeGatewayReachable.mockResolvedValue({ ok: true });
15531544

15541545
await finalizeSetupWizard({
15551546
flow: "advanced",
@@ -1558,8 +1549,7 @@ describe("finalizeSetupWizard", () => {
15581549
authChoice: "skip",
15591550
installDaemon: false,
15601551
skipHealth: true,
1561-
skipUi: true,
1562-
suppressGatewayTokenOutput: true,
1552+
skipUi: false,
15631553
},
15641554
baseConfig: {},
15651555
nextConfig: {},
@@ -1572,16 +1562,21 @@ describe("finalizeSetupWizard", () => {
15721562
tailscaleMode: "off",
15731563
},
15741564
prompter,
1575-
runtime: createRuntime(),
1565+
runtime,
15761566
});
15771567

1578-
const output = vi
1579-
.mocked(prompter.note)
1580-
.mock.calls.map((call) => call.join("\n"))
1568+
const terminalOutput = [prompter.note, prompter.outro]
1569+
.flatMap((writer) => vi.mocked(writer).mock.calls.flat())
15811570
.join("\n");
1582-
expect(output).toContain("http://127.0.0.1:18789");
1583-
expect(output).not.toContain("session-token");
1584-
expect(output).not.toContain("#token=");
1571+
const runtimeOutput = [runtimeLog, runtimeError]
1572+
.flatMap((writer) => writer.mock.calls.flat())
1573+
.join("\n");
1574+
expect(terminalOutput).toContain("http://127.0.0.1:18789");
1575+
expect(terminalOutput).toContain("openclaw dashboard --no-open");
1576+
for (const output of [terminalOutput, runtimeOutput]) {
1577+
expect(output).not.toContain("session-token");
1578+
expect(output).not.toContain("#token=");
1579+
}
15851580
});
15861581

15871582
it("stops after a scheduled restart instead of reinstalling the service", async () => {

‎src/wizard/setup.finalize.ts‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import { resolveGatewayInstallToken } from "../commands/gateway-install-token.js
2323
import { formatHealthCheckFailure } from "../commands/health-format.js";
2424
import { healthCommand } from "../commands/health.js";
2525
import {
26-
buildOnboardingControlUiUrl,
2726
probeGatewayReachable,
2827
waitForGatewayReachable,
2928
resolveAdvertisedControlUiLinks,
@@ -507,7 +506,6 @@ export async function finalizeSetupWizard(
507506
options: FinalizeOnboardingOptions,
508507
): Promise<{ launchedTui: boolean }> {
509508
const { flow, opts, baseConfig, nextConfig, settings, prompter, runtime } = options;
510-
const suppressGatewayTokenOutput = opts.suppressGatewayTokenOutput === true;
511509
let gatewayProbe: { ok: boolean; detail?: string } = { ok: true };
512510
let resolvedGatewayPassword = "";
513511
let sessionGateway: import("../gateway/server.js").GatewayServer | undefined;
@@ -668,12 +666,6 @@ export async function finalizeSetupWizard(
668666
basePath: controlUiBasePath,
669667
tlsEnabled: nextConfig.gateway?.tls?.enabled === true,
670668
});
671-
const authedUrl = buildOnboardingControlUiUrl({
672-
httpUrl: displayLinks.httpUrl,
673-
authMode: settings.authMode,
674-
token: settings.gatewayToken,
675-
suppressTokenOutput: suppressGatewayTokenOutput,
676-
});
677669
if (gateway.status !== "failed" && (opts.skipHealth || !gatewayProbe.ok)) {
678670
gatewayProbe = await probeGatewayReachable({
679671
url: probeLinks.wsUrl,
@@ -766,14 +758,6 @@ export async function finalizeSetupWizard(
766758
await prompter.note(
767759
[
768760
dashboardReady ? t("wizard.finalize.webUiUrl", { url: displayLinks.httpUrl }) : undefined,
769-
dashboardReady &&
770-
!opts.skipUi &&
771-
gatewayProbe.ok &&
772-
settings.authMode === "token" &&
773-
settings.gatewayToken &&
774-
!suppressGatewayTokenOutput
775-
? t("wizard.finalize.webUiWithTokenUrl", { url: authedUrl })
776-
: undefined,
777761
t("wizard.finalize.gatewayWsUrl", { url: displayLinks.wsUrl }),
778762
gatewayStatusLine,
779763
...windowsFirewallLines,
@@ -820,11 +804,9 @@ export async function finalizeSetupWizard(
820804
t("wizard.finalize.gatewayTokenGenerate", {
821805
command: formatCliCommand("openclaw doctor --generate-gateway-token"),
822806
}),
823-
suppressGatewayTokenOutput ? undefined : t("wizard.finalize.dashboardTokenMemory"),
824807
t("wizard.finalize.dashboardOpenAnytime", {
825808
command: formatCliCommand("openclaw dashboard --no-open"),
826809
}),
827-
suppressGatewayTokenOutput ? undefined : t("wizard.finalize.dashboardTokenPrompt"),
828810
].filter(Boolean);
829811
await prompter.note(tokenNotes.join("\n"), "Token");
830812
}

0 commit comments

Comments
 (0)