mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-25 02:13:31 +00:00
Gateway: add SecretRef support for gateway.auth.token with auth-mode guardrails (#35094)
This commit is contained in:
@@ -107,7 +107,11 @@ import {
|
||||
refreshGatewayHealthSnapshot,
|
||||
} from "./server/health-state.js";
|
||||
import { loadGatewayTlsRuntime } from "./server/tls.js";
|
||||
import { ensureGatewayStartupAuth } from "./startup-auth.js";
|
||||
import {
|
||||
ensureGatewayStartupAuth,
|
||||
mergeGatewayAuthConfig,
|
||||
mergeGatewayTailscaleConfig,
|
||||
} from "./startup-auth.js";
|
||||
import { maybeSeedControlUiAllowedOriginsAtStartup } from "./startup-control-ui-origins.js";
|
||||
|
||||
export { __resetModelCatalogCacheForTest } from "./server-model-catalog.js";
|
||||
@@ -174,6 +178,23 @@ function logGatewayAuthSurfaceDiagnostics(prepared: {
|
||||
}
|
||||
}
|
||||
|
||||
function applyGatewayAuthOverridesForStartupPreflight(
|
||||
config: OpenClawConfig,
|
||||
overrides: Pick<GatewayServerOptions, "auth" | "tailscale">,
|
||||
): OpenClawConfig {
|
||||
if (!overrides.auth && !overrides.tailscale) {
|
||||
return config;
|
||||
}
|
||||
return {
|
||||
...config,
|
||||
gateway: {
|
||||
...config.gateway,
|
||||
auth: mergeGatewayAuthConfig(config.gateway?.auth, overrides.auth),
|
||||
tailscale: mergeGatewayTailscaleConfig(config.gateway?.tailscale, overrides.tailscale),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export type GatewayServer = {
|
||||
close: (opts?: { reason?: string; restartExpectedMs?: number | null }) => Promise<void>;
|
||||
};
|
||||
@@ -373,7 +394,14 @@ export async function startGatewayServer(
|
||||
: "Unknown validation issue.";
|
||||
throw new Error(`Invalid config at ${freshSnapshot.path}.\n${issues}`);
|
||||
}
|
||||
await activateRuntimeSecrets(freshSnapshot.config, {
|
||||
const startupPreflightConfig = applyGatewayAuthOverridesForStartupPreflight(
|
||||
freshSnapshot.config,
|
||||
{
|
||||
auth: opts.auth,
|
||||
tailscale: opts.tailscale,
|
||||
},
|
||||
);
|
||||
await activateRuntimeSecrets(startupPreflightConfig, {
|
||||
reason: "startup",
|
||||
activate: false,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user