惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
B
Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
GbyAI
GbyAI
IT之家
IT之家
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
博客园_首页
C
Check Point Blog
博客园 - 【当耐特】
美团技术团队
Last Week in AI
Last Week in AI
A
About on SuperTechFans
雷峰网
雷峰网
MongoDB | Blog
MongoDB | Blog
Microsoft Azure Blog
Microsoft Azure Blog
M
MIT News - Artificial intelligence
Martin Fowler
Martin Fowler
J
Java Code Geeks
B
Blog RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
G
Google Developers Blog
F
Fortinet All Blogs

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: align runtime auth evidence with config trust · open...
shakkernerd · 2026-04-30 · via Recent Commits to openclaw:main

@@ -15,6 +15,7 @@ import {

1515

hasAvailableAuthForProvider,

1616

resolveApiKeyForProvider,

1717

resolveEnvApiKey,

18+

resolveModelAuthMode,

1819

} from "./model-auth.js";

19202021

async function expectVertexAdcEnvApiKey(params: {

@@ -90,6 +91,17 @@ vi.mock("./provider-auth-aliases.js", () => ({

9091

}));

91929293

vi.mock("./model-auth-env-vars.js", () => {

94+

const hasAllowedPlugin = (config: unknown, pluginId: string): boolean => {

95+

if (!config || typeof config !== "object") {

96+

return false;

97+

}

98+

const plugins = (config as { plugins?: unknown }).plugins;

99+

if (!plugins || typeof plugins !== "object") {

100+

return false;

101+

}

102+

const allow = (plugins as { allow?: unknown }).allow;

103+

return Array.isArray(allow) && allow.includes(pluginId);

104+

};

93105

const candidates = {

94106

anthropic: ["ANTHROPIC_OAUTH_TOKEN", "ANTHROPIC_API_KEY"],

95107

google: ["GEMINI_API_KEY", "GOOGLE_API_KEY"],

@@ -110,19 +122,35 @@ vi.mock("./model-auth-env-vars.js", () => {

110122

PROVIDER_ENV_API_KEY_CANDIDATES: candidates,

111123

listKnownProviderEnvApiKeyNames: () => [...new Set(Object.values(candidates).flat())],

112124

resolveProviderEnvApiKeyCandidates: () => candidates,

113-

resolveProviderEnvAuthEvidence: () => ({

114-

"google-vertex": [

115-

{

116-

type: "local-file-with-env",

117-

fileEnvVar: "GOOGLE_APPLICATION_CREDENTIALS",

118-

fallbackPaths: ["${HOME}/.config/gcloud/application_default_credentials.json"],

119-

requiresAnyEnv: ["GOOGLE_CLOUD_PROJECT", "GCLOUD_PROJECT"],

120-

requiresAllEnv: ["GOOGLE_CLOUD_LOCATION"],

121-

credentialMarker: "gcp-vertex-credentials",

122-

source: "gcloud adc",

123-

},

124-

],

125-

}),

125+

resolveProviderEnvAuthEvidence: (params?: { config?: OpenClawConfig }) => {

126+

const evidence = {

127+

"google-vertex": [

128+

{

129+

type: "local-file-with-env",

130+

fileEnvVar: "GOOGLE_APPLICATION_CREDENTIALS",

131+

fallbackPaths: ["${HOME}/.config/gcloud/application_default_credentials.json"],

132+

requiresAnyEnv: ["GOOGLE_CLOUD_PROJECT", "GCLOUD_PROJECT"],

133+

requiresAllEnv: ["GOOGLE_CLOUD_LOCATION"],

134+

credentialMarker: "gcp-vertex-credentials",

135+

source: "gcloud adc",

136+

},

137+

],

138+

} satisfies Record<string, readonly unknown[]>;

139+

if (!hasAllowedPlugin(params?.config, "workspace-cloud")) {

140+

return evidence;

141+

}

142+

return {

143+

...evidence,

144+

"workspace-cloud": [

145+

{

146+

type: "local-file-with-env",

147+

fileEnvVar: "WORKSPACE_CLOUD_CREDENTIALS",

148+

credentialMarker: "workspace-cloud-local-credentials",

149+

source: "workspace cloud credentials",

150+

},

151+

],

152+

};

153+

},

126154

};

127155

});

128156

@@ -436,6 +464,67 @@ describe("getApiKeyForModel", () => {

436464

});

437465

});

438466467+

it("uses trusted workspace manifest auth evidence in runtime auth checks", async () => {

468+

const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-workspace-cloud-auth-"));

469+

const credentialsPath = path.join(tempDir, "credentials.json");

470+

await fs.writeFile(credentialsPath, "{}", "utf8");

471+472+

const cfg: OpenClawConfig = {

473+

plugins: {

474+

allow: ["workspace-cloud"],

475+

},

476+

};

477+478+

try {

479+

await withEnvAsync({ WORKSPACE_CLOUD_CREDENTIALS: credentialsPath }, async () => {

480+

const store = { version: 1 as const, profiles: {} };

481+

const resolved = await resolveApiKeyForProvider({

482+

provider: "workspace-cloud",

483+

cfg,

484+

store,

485+

});

486+487+

expect(resolved).toEqual({

488+

apiKey: "workspace-cloud-local-credentials",

489+

source: "workspace cloud credentials",

490+

mode: "api-key",

491+

});

492+

expect(resolveModelAuthMode("workspace-cloud", cfg, store)).toBe("api-key");

493+

await expect(

494+

hasAvailableAuthForProvider({

495+

provider: "workspace-cloud",

496+

cfg,

497+

store,

498+

}),

499+

).resolves.toBe(true);

500+

});

501+

} finally {

502+

await fs.rm(tempDir, { recursive: true, force: true });

503+

}

504+

});

505+506+

it("ignores untrusted workspace manifest auth evidence in runtime auth checks", async () => {

507+

const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-workspace-cloud-auth-"));

508+

const credentialsPath = path.join(tempDir, "credentials.json");

509+

await fs.writeFile(credentialsPath, "{}", "utf8");

510+511+

try {

512+

await withEnvAsync({ WORKSPACE_CLOUD_CREDENTIALS: credentialsPath }, async () => {

513+

const store = { version: 1 as const, profiles: {} };

514+

expect(resolveModelAuthMode("workspace-cloud", { plugins: {} }, store)).toBe("unknown");

515+

await expect(

516+

hasAvailableAuthForProvider({

517+

provider: "workspace-cloud",

518+

cfg: { plugins: {} },

519+

store,

520+

}),

521+

).resolves.toBe(false);

522+

});

523+

} finally {

524+

await fs.rm(tempDir, { recursive: true, force: true });

525+

}

526+

});

527+439528

it("hasAvailableAuthForProvider('google') accepts GOOGLE_API_KEY fallback", async () => {

440529

await withEnvAsync(

441530

{