Skip to content

Commit d9766c3

Browse files
fix(wizard): honor remote password auth in probes (#118134)
* fix(wizard): honor remote password auth in probes * fix(wizard): preserve remote probe auth policy * test(wizard): keep remote probe coverage focused * fix(gateway): preserve remote probe secret refs * fix(gateway): isolate remote probe credentials * fix(wizard): authenticate remote health checks * fix(gateway): unify remote probe auth precedence * test(gateway): align remote probe auth coverage * fix(gateway): preserve disabled exec-ref guard * fix(gateway): block failed remote ref fallback * test(gateway): follow consolidated probe coverage * fix(wizard): stop health after unresolved remote auth * fix(gateway): preserve configured sibling probe auth * fix(wizard): bind remote health target * docs(gateway): clarify remote probe auth precedence --------- Co-authored-by: IWhatsskill <[email protected]> Co-authored-by: Dallin Romney <[email protected]>
1 parent b336984 commit d9766c3

14 files changed

Lines changed: 727 additions & 180 deletions

‎docs/gateway/remote.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,12 @@ Gateway credential resolution follows one shared contract across call/probe/stat
106106
- token: `gateway.remote.token` -> `OPENCLAW_GATEWAY_TOKEN` -> `gateway.auth.token`
107107
- password: `OPENCLAW_GATEWAY_PASSWORD` -> `gateway.remote.password` -> `gateway.auth.password`
108108
- Node-host local-mode exception: environment credentials stay first and `gateway.remote.token` / `gateway.remote.password` are ignored because node commands target an explicit host and port.
109-
- Remote probe/status token checks are strict by default: they use `gateway.remote.token` only (no local token fallback) when targeting remote mode.
109+
- Remote startup/status/wizard probes with SecretRef support treat configured
110+
`gateway.remote.token` and `gateway.remote.password` as authoritative for the configured
111+
target. Ambient environment credentials are considered only when neither remote credential
112+
is configured. If a configured remote SecretRef cannot be resolved, the probe warns and does
113+
not fall back to environment credentials; a separately configured sibling credential that
114+
resolves successfully remains usable.
110115
- Gateway env overrides use `OPENCLAW_GATEWAY_*` only.
111116

112117
## Chat UI remote access

‎src/cli/daemon-cli/status.gather.test.ts‎

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,44 @@ describe("gatherDaemonStatus", () => {
10931093
);
10941094
});
10951095

1096+
it("skips remote password exec SecretRef auth despite an ambient password", async () => {
1097+
daemonLoadedConfig = {
1098+
gateway: {
1099+
mode: "remote",
1100+
remote: {
1101+
url: "wss://gateway.example",
1102+
password: { source: "exec", provider: "vault", id: "gateway/remote-password" },
1103+
},
1104+
},
1105+
secrets: {
1106+
providers: {
1107+
vault: { source: "exec", command: "/bin/false" },
1108+
},
1109+
},
1110+
};
1111+
setTestEnvValue("OPENCLAW_GATEWAY_PASSWORD", "ambient-password"); // pragma: allowlist secret
1112+
1113+
const status = await gatherDaemonStatus({
1114+
rpc: {},
1115+
probe: true,
1116+
deep: false,
1117+
allowExecSecretRefs: false,
1118+
});
1119+
1120+
expect(resolveGatewayProbeAuthSafeWithSecretInputsCalls).not.toHaveBeenCalled();
1121+
const probeInput = callArg(callGatewayStatusProbe) as {
1122+
token?: string;
1123+
password?: string;
1124+
allowRpcConfigCredentials?: boolean;
1125+
};
1126+
expect(probeInput.token).toBeUndefined();
1127+
expect(probeInput.password).toBeUndefined();
1128+
expect(probeInput.allowRpcConfigCredentials).toBe(false);
1129+
expect(status.rpc?.authWarning).toContain(
1130+
"gateway credentials use an exec SecretRef and exec SecretRefs are disabled",
1131+
);
1132+
});
1133+
10961134
it("ignores remote exec SecretRefs for local probes when exec refs are disabled", async () => {
10971135
daemonLoadedConfig = {
10981136
gateway: {
@@ -1229,7 +1267,7 @@ describe("gatherDaemonStatus", () => {
12291267
expect(status.rpc?.authWarning).toContain("probing without configured auth credentials");
12301268
});
12311269

1232-
it("keeps remote probe auth strict when remote token is missing", async () => {
1270+
it("keeps configured remote password authoritative for remote probes", async () => {
12331271
daemonLoadedConfig = {
12341272
gateway: {
12351273
mode: "remote",
@@ -1251,7 +1289,7 @@ describe("gatherDaemonStatus", () => {
12511289

12521290
const probeInput = callArg(callGatewayStatusProbe) as { token?: string; password?: string };
12531291
expect(probeInput.token).toBeUndefined();
1254-
expect(probeInput.password).toBe("env-password"); // pragma: allowlist secret
1292+
expect(probeInput.password).toBe("remote-password"); // pragma: allowlist secret
12551293
});
12561294

12571295
it("skips TLS runtime loading when probe is disabled", async () => {

‎src/cli/daemon-cli/status.gather.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,10 @@ function hasActiveGatewayExecProbeCredential(params: {
568568
explicitAuth: params.explicitAuth,
569569
modeOverride: params.mode,
570570
path,
571+
// Remote probe config suppresses ambient credentials across auth types.
572+
// Mirror that owner here so env auth cannot hide a winning exec ref.
571573
remoteTokenFallback: "remote-only",
574+
remotePasswordFallback: "remote-only",
572575
})
573576
) {
574577
return false;
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import { vi, type Mock } from "vitest";
2+
import type { OpenClawConfig } from "../config/config.js";
3+
4+
export const EMPTY_CONFIG_SNAPSHOT = {
5+
exists: false,
6+
valid: true,
7+
config: {},
8+
issues: [],
9+
};
10+
11+
export function createWizardTestRuntime() {
12+
return {
13+
log: vi.fn(),
14+
error: vi.fn(),
15+
exit: vi.fn(),
16+
};
17+
}
18+
19+
type WizardStateMocks = {
20+
readConfigFileSnapshot: Mock;
21+
resolveGatewayPort: Mock;
22+
probeGatewayReachable: Mock;
23+
resolveControlUiLinks: Mock;
24+
resolveLocalControlUiProbeLinks: Mock;
25+
resolveAdvertisedControlUiLinks: Mock;
26+
inspectWindowsGatewayFirewall: Mock;
27+
summarizeExistingConfig: Mock;
28+
createClackPrompter: Mock;
29+
};
30+
31+
export function setupBaseWizardTestState(mocks: WizardStateMocks, config: OpenClawConfig = {}) {
32+
mocks.readConfigFileSnapshot.mockResolvedValue({ ...EMPTY_CONFIG_SNAPSHOT, config });
33+
mocks.resolveGatewayPort.mockReturnValue(18789);
34+
mocks.probeGatewayReachable.mockResolvedValue({ ok: false });
35+
mocks.resolveControlUiLinks.mockReturnValue({ wsUrl: "ws://127.0.0.1:18789" });
36+
mocks.resolveLocalControlUiProbeLinks.mockReturnValue({
37+
httpUrl: "http://127.0.0.1:18789/",
38+
wsUrl: "ws://127.0.0.1:18789",
39+
});
40+
mocks.resolveAdvertisedControlUiLinks.mockResolvedValue({
41+
httpUrl: "http://127.0.0.1:18789/",
42+
wsUrl: "ws://127.0.0.1:18789",
43+
});
44+
mocks.inspectWindowsGatewayFirewall.mockResolvedValue({
45+
applies: false,
46+
severity: "info",
47+
code: "windows_firewall_not_applicable",
48+
message: "Windows LAN firewall diagnostics do not apply.",
49+
details: [],
50+
});
51+
mocks.summarizeExistingConfig.mockReturnValue("");
52+
mocks.createClackPrompter.mockReturnValue({
53+
intro: vi.fn(async () => {}),
54+
outro: vi.fn(async () => {}),
55+
note: vi.fn(async () => {}),
56+
select: vi.fn(async () => "firecrawl"),
57+
multiselect: vi.fn(async () => []),
58+
text: vi.fn(async () => ""),
59+
confirm: vi.fn(async () => true),
60+
progress: vi.fn(() => ({ update: vi.fn(), stop: vi.fn() })),
61+
});
62+
}
63+
64+
export function queueWizardTestPrompts(
65+
mocks: {
66+
clackSelect: Mock;
67+
clackConfirm: Mock;
68+
clackText: Mock;
69+
clackIntro: Mock;
70+
clackOutro: Mock;
71+
},
72+
params: { select: string[]; confirm: boolean[]; text?: string },
73+
) {
74+
const selectQueue = [...params.select];
75+
const confirmQueue = [...params.confirm];
76+
mocks.clackSelect.mockImplementation(async () => selectQueue.shift());
77+
mocks.clackConfirm.mockImplementation(async () => confirmQueue.shift());
78+
mocks.clackText.mockResolvedValue(params.text ?? "");
79+
mocks.clackIntro.mockResolvedValue(undefined);
80+
mocks.clackOutro.mockResolvedValue(undefined);
81+
}
82+
83+
export function createSearchProviderOption(overrides: Record<string, unknown>) {
84+
return overrides;
85+
}
86+
87+
export function createEnabledWebSearchConfig(
88+
provider: string,
89+
pluginEntry: Record<string, unknown>,
90+
) {
91+
return (cfg: OpenClawConfig) => ({
92+
...cfg,
93+
tools: {
94+
...cfg.tools,
95+
web: {
96+
...cfg.tools?.web,
97+
search: {
98+
provider,
99+
enabled: true,
100+
},
101+
},
102+
},
103+
plugins: {
104+
...cfg.plugins,
105+
entries: {
106+
...cfg.plugins?.entries,
107+
[provider]: pluginEntry,
108+
},
109+
},
110+
});
111+
}

0 commit comments

Comments
 (0)