fix(auth): grant senderIsOwner for internal channels with operator.admin scope (openclaw#35704)

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: Naylenv <45486779+Naylenv@users.noreply.github.com>
Co-authored-by: Octane0411 <88922959+Octane0411@users.noreply.github.com>
Co-authored-by: Sid-Qin <201593046+Sid-Qin@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
Sid
2026-03-06 06:32:42 +08:00
committed by GitHub
parent aad372e15f
commit 60d33637d9
3 changed files with 58 additions and 2 deletions

View File

@@ -141,6 +141,7 @@ Docs: https://docs.openclaw.ai
- Agents/failover cooldown classification: stop treating generic `cooling down` text as provider `rate_limit` so healthy models no longer show false global cooldown/rate-limit warnings while explicit `model_cooldown` markers still trigger failover. (#32972) thanks @stakeswky.
- Agents/failover service-unavailable handling: stop treating bare proxy/CDN `service unavailable` errors as provider overload while keeping them retryable via the timeout/failover path, so transient outages no longer show false rate-limit warnings or block fallback. (#36646) thanks @jnMetaCode.
- Agents/current-time UTC anchor: append a machine-readable UTC suffix alongside local `Current time:` lines in shared cron-style prompt contexts so agents can compare UTC-stamped workspace timestamps without doing timezone math. (#32423) thanks @jriff.
- TUI/webchat command-owner scope alignment: treat internal-channel gateway sessions with `operator.admin` as owner-authorized in command auth, restoring cron/gateway/connector tool access for affected TUI/webchat sessions while keeping external channels on identity-based owner checks. (from #35666, #35673, #35704) Thanks @Naylenv, @Octane0411, and @Sid-Qin.
## 2026.3.2

View File

@@ -3,7 +3,11 @@ import { getChannelDock, listChannelDocks } from "../channels/dock.js";
import type { ChannelId } from "../channels/plugins/types.js";
import { normalizeAnyChannelId } from "../channels/registry.js";
import type { OpenClawConfig } from "../config/config.js";
import { INTERNAL_MESSAGE_CHANNEL, normalizeMessageChannel } from "../utils/message-channel.js";
import {
INTERNAL_MESSAGE_CHANNEL,
isInternalMessageChannel,
normalizeMessageChannel,
} from "../utils/message-channel.js";
import type { MsgContext } from "./templating.js";
export type CommandAuthorization = {
@@ -341,7 +345,12 @@ export function resolveCommandAuthorization(params: {
const senderId = matchedSender ?? senderCandidates[0];
const enforceOwner = Boolean(dock?.commands?.enforceOwnerForCommands);
const senderIsOwner = Boolean(matchedSender);
const senderIsOwnerByIdentity = Boolean(matchedSender);
const senderIsOwnerByScope =
isInternalMessageChannel(ctx.Provider) &&
Array.isArray(ctx.GatewayClientScopes) &&
ctx.GatewayClientScopes.includes("operator.admin");
const senderIsOwner = senderIsOwnerByIdentity || senderIsOwnerByScope;
const ownerAllowlistConfigured = ownerAllowAll || explicitOwners.length > 0;
const requireOwner = enforceOwner || ownerAllowlistConfigured;
const isOwnerForCommands = !requireOwner

View File

@@ -458,6 +458,52 @@ describe("resolveCommandAuthorization", () => {
expect(deniedAuth.isAuthorizedSender).toBe(false);
});
});
it("grants senderIsOwner for internal channel with operator.admin scope", () => {
const cfg = {} as OpenClawConfig;
const ctx = {
Provider: "webchat",
Surface: "webchat",
GatewayClientScopes: ["operator.admin"],
} as MsgContext;
const auth = resolveCommandAuthorization({
ctx,
cfg,
commandAuthorized: true,
});
expect(auth.senderIsOwner).toBe(true);
});
it("does not grant senderIsOwner for internal channel without admin scope", () => {
const cfg = {} as OpenClawConfig;
const ctx = {
Provider: "webchat",
Surface: "webchat",
GatewayClientScopes: ["operator.approvals"],
} as MsgContext;
const auth = resolveCommandAuthorization({
ctx,
cfg,
commandAuthorized: true,
});
expect(auth.senderIsOwner).toBe(false);
});
it("does not grant senderIsOwner for external channel even with admin scope", () => {
const cfg = {} as OpenClawConfig;
const ctx = {
Provider: "telegram",
Surface: "telegram",
From: "telegram:12345",
GatewayClientScopes: ["operator.admin"],
} as MsgContext;
const auth = resolveCommandAuthorization({
ctx,
cfg,
commandAuthorized: true,
});
expect(auth.senderIsOwner).toBe(false);
});
});
describe("control command parsing", () => {