refactor(security): unify gateway scope authorization flows

This commit is contained in:
Peter Steinberger
2026-02-19 15:06:28 +01:00
parent f4b288b8f7
commit 2777d8ad93
14 changed files with 202 additions and 86 deletions

View File

@@ -13,6 +13,7 @@ const setRegistry = (registry: ReturnType<typeof createTestRegistry>) => {
const callGatewayMock = vi.fn();
vi.mock("../../gateway/call.js", () => ({
callGateway: (...args: unknown[]) => callGatewayMock(...args),
callGatewayLeastPrivilege: (...args: unknown[]) => callGatewayMock(...args),
randomIdempotencyKey: () => "idem-1",
}));

View File

@@ -1,7 +1,7 @@
import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js";
import type { OpenClawConfig } from "../../config/config.js";
import { loadConfig } from "../../config/config.js";
import { callGateway, randomIdempotencyKey } from "../../gateway/call.js";
import { callGatewayLeastPrivilege, randomIdempotencyKey } from "../../gateway/call.js";
import type { PollInput } from "../../polls.js";
import { normalizePollInput } from "../../polls.js";
import {
@@ -151,7 +151,7 @@ async function callMessageGateway<T>(params: {
params: Record<string, unknown>;
}): Promise<T> {
const gateway = resolveGatewayOptions(params.gateway);
return await callGateway<T>({
return await callGatewayLeastPrivilege<T>({
url: gateway.url,
token: gateway.token,
method: params.method,