mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-25 06:23:32 +00:00
SecretRef: harden custom/provider secret persistence and reuse (#42554)
* Models: gate custom provider keys by usable secret semantics * Config: project runtime writes onto source snapshot * Models: prevent stale apiKey preservation for marker-managed providers * Runner: strip SecretRef marker headers from resolved models * Secrets: scan active agent models.json path in audit * Config: guard runtime-source projection for unrelated configs * Extensions: fix onboarding type errors in CI * Tests: align setup helper account-enabled expectation * Secrets audit: harden models.json file reads * fix: harden SecretRef custom/provider secret persistence (#42554) (thanks @joshavant)
This commit is contained in:
committed by
Peter Steinberger
parent
20237358d9
commit
36d2ae2a22
@@ -9,7 +9,7 @@ import {
|
||||
resolveAuthProfileOrder,
|
||||
} from "../agents/auth-profiles.js";
|
||||
import { isNonSecretApiKeyMarker } from "../agents/model-auth-markers.js";
|
||||
import { getCustomProviderApiKey } from "../agents/model-auth.js";
|
||||
import { resolveUsableCustomProviderApiKey } from "../agents/model-auth.js";
|
||||
import { normalizeProviderId } from "../agents/model-selection.js";
|
||||
import { loadConfig } from "../config/config.js";
|
||||
import { normalizeSecretInput } from "../utils/normalize-secret-input.js";
|
||||
@@ -42,7 +42,9 @@ function resolveZaiApiKey(): string | undefined {
|
||||
}
|
||||
|
||||
const cfg = loadConfig();
|
||||
const key = getCustomProviderApiKey(cfg, "zai") || getCustomProviderApiKey(cfg, "z-ai");
|
||||
const key =
|
||||
resolveUsableCustomProviderApiKey({ cfg, provider: "zai" })?.apiKey ??
|
||||
resolveUsableCustomProviderApiKey({ cfg, provider: "z-ai" })?.apiKey;
|
||||
if (key) {
|
||||
return key;
|
||||
}
|
||||
@@ -103,8 +105,11 @@ function resolveProviderApiKeyFromConfigAndStore(params: {
|
||||
}
|
||||
|
||||
const cfg = loadConfig();
|
||||
const key = getCustomProviderApiKey(cfg, params.providerId);
|
||||
if (key && !isNonSecretApiKeyMarker(key)) {
|
||||
const key = resolveUsableCustomProviderApiKey({
|
||||
cfg,
|
||||
provider: params.providerId,
|
||||
})?.apiKey;
|
||||
if (key) {
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user