mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 09:12:42 +00:00
refactor: unify gateway SecretRef auth resolution paths
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
import type { Command } from "commander";
|
||||
import qrcode from "qrcode-terminal";
|
||||
import { loadConfig } from "../config/config.js";
|
||||
import { hasConfiguredSecretInput, resolveSecretInputRef } from "../config/types.secrets.js";
|
||||
import { hasConfiguredSecretInput } from "../config/types.secrets.js";
|
||||
import { readGatewayPasswordEnv, readGatewayTokenEnv } from "../gateway/credentials.js";
|
||||
import { resolveRequiredConfiguredSecretRefInputString } from "../gateway/resolve-configured-secret-input-string.js";
|
||||
import { resolvePairingSetupFromConfig, encodePairingSetupCode } from "../pairing/setup-code.js";
|
||||
import { runCommandWithTimeout } from "../process/exec.js";
|
||||
import { defaultRuntime } from "../runtime.js";
|
||||
import { secretRefKey } from "../secrets/ref-contract.js";
|
||||
import { resolveSecretRefValues } from "../secrets/resolve.js";
|
||||
import { formatDocsLink } from "../terminal/links.js";
|
||||
import { theme } from "../terminal/theme.js";
|
||||
import { resolveCommandSecretRefsViaGateway } from "./command-secret-gateway.js";
|
||||
@@ -66,26 +65,19 @@ function shouldResolveLocalGatewayPasswordSecret(
|
||||
async function resolveLocalGatewayPasswordSecretIfNeeded(
|
||||
cfg: ReturnType<typeof loadConfig>,
|
||||
): Promise<void> {
|
||||
const authPassword = cfg.gateway?.auth?.password;
|
||||
const { ref } = resolveSecretInputRef({
|
||||
value: authPassword,
|
||||
defaults: cfg.secrets?.defaults,
|
||||
});
|
||||
if (!ref) {
|
||||
return;
|
||||
}
|
||||
const resolved = await resolveSecretRefValues([ref], {
|
||||
const resolvedPassword = await resolveRequiredConfiguredSecretRefInputString({
|
||||
config: cfg,
|
||||
env: process.env,
|
||||
value: cfg.gateway?.auth?.password,
|
||||
path: "gateway.auth.password",
|
||||
});
|
||||
const value = resolved.get(secretRefKey(ref));
|
||||
if (typeof value !== "string" || value.trim().length === 0) {
|
||||
throw new Error("gateway.auth.password resolved to an empty or non-string value.");
|
||||
if (!resolvedPassword) {
|
||||
return;
|
||||
}
|
||||
if (!cfg.gateway?.auth) {
|
||||
return;
|
||||
}
|
||||
cfg.gateway.auth.password = value.trim();
|
||||
cfg.gateway.auth.password = resolvedPassword;
|
||||
}
|
||||
|
||||
function emitQrSecretResolveDiagnostics(diagnostics: string[], opts: QrCliOptions): void {
|
||||
|
||||
Reference in New Issue
Block a user