Skip to content

Commit 55d492b

Browse files
committed
Gateway: allow operator admin scope for pairing and approvals
1 parent 68cb4fc commit 55d492b

3 files changed

Lines changed: 34 additions & 6 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Docs: https://docs.openclaw.ai
2525
- Agents/Fallbacks: treat JSON payloads with `type: "api_error"` + `"Internal server error"` as transient failover errors so Anthropic 500-style failures trigger model fallback. (#23193) Thanks @jarvis-lane.
2626
- Agents/Diagnostics: include resolved lifecycle error text in `embedded run agent end` warnings so UI/TUI “Connection error” runs expose actionable provider failure reasons in gateway logs. (#23054) Thanks @Raize.
2727
- Gateway/Pairing: treat operator.admin pairing tokens as satisfying operator.write requests so legacy devices stop looping through scope-upgrade prompts introduced in 2026.2.19. (#23125, #23006) Thanks @vignesh07.
28+
- Gateway/Pairing: treat `operator.admin` as satisfying other `operator.*` scope checks during device-auth verification so local CLI/TUI sessions stop entering pairing-required loops for pairing/approval-scoped commands. (#22062, #22193, #21191) Thanks @Botaccess, @jhartshorn, and @ctbritt.
2829
- Memory/QMD: add optional `memory.qmd.mcporter` search routing so QMD `query/search/vsearch` can run through mcporter keep-alive flows (including multi-collection paths) to reduce cold starts, while keeping searches on agent-scoped QMD state for consistent recall. (#19617) Thanks @nicole-luxe and @vignesh07.
2930
- Chat/UI: strip inline reply/audio directive tags (`[[reply_to_current]]`, `[[reply_to:<id>]]`, `[[audio_as_voice]]`) from displayed chat history, live chat event output, and session preview snippets so control tags no longer leak into user-visible surfaces.
3031
- BlueBubbles/DM history: restore DM backfill context with account-scoped rolling history, bounded backfill retries, and safer history payload limits. (#20302) Thanks @Ryan-Haines.

‎src/shared/operator-scope-compat.test.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,33 @@ describe("roleScopesAllow", () => {
4343
).toBe(true);
4444
});
4545

46+
it("treats operator.approvals/operator.pairing as satisfied by operator.admin", () => {
47+
expect(
48+
roleScopesAllow({
49+
role: "operator",
50+
requestedScopes: ["operator.approvals"],
51+
allowedScopes: ["operator.admin"],
52+
}),
53+
).toBe(true);
54+
expect(
55+
roleScopesAllow({
56+
role: "operator",
57+
requestedScopes: ["operator.pairing"],
58+
allowedScopes: ["operator.admin"],
59+
}),
60+
).toBe(true);
61+
});
62+
63+
it("does not treat operator.admin as satisfying non-operator scopes", () => {
64+
expect(
65+
roleScopesAllow({
66+
role: "operator",
67+
requestedScopes: ["system.run"],
68+
allowedScopes: ["operator.admin"],
69+
}),
70+
).toBe(false);
71+
});
72+
4673
it("uses strict matching for non-operator roles", () => {
4774
expect(
4875
roleScopesAllow({

‎src/shared/operator-scope-compat.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const OPERATOR_ROLE = "operator";
22
const OPERATOR_ADMIN_SCOPE = "operator.admin";
33
const OPERATOR_READ_SCOPE = "operator.read";
44
const OPERATOR_WRITE_SCOPE = "operator.write";
5+
const OPERATOR_SCOPE_PREFIX = "operator.";
56

67
function normalizeScopeList(scopes: readonly string[]): string[] {
78
const out = new Set<string>();
@@ -15,15 +16,14 @@ function normalizeScopeList(scopes: readonly string[]): string[] {
1516
}
1617

1718
function operatorScopeSatisfied(requestedScope: string, granted: Set<string>): boolean {
19+
if (granted.has(OPERATOR_ADMIN_SCOPE) && requestedScope.startsWith(OPERATOR_SCOPE_PREFIX)) {
20+
return true;
21+
}
1822
if (requestedScope === OPERATOR_READ_SCOPE) {
19-
return (
20-
granted.has(OPERATOR_READ_SCOPE) ||
21-
granted.has(OPERATOR_WRITE_SCOPE) ||
22-
granted.has(OPERATOR_ADMIN_SCOPE)
23-
);
23+
return granted.has(OPERATOR_READ_SCOPE) || granted.has(OPERATOR_WRITE_SCOPE);
2424
}
2525
if (requestedScope === OPERATOR_WRITE_SCOPE) {
26-
return granted.has(OPERATOR_WRITE_SCOPE) || granted.has(OPERATOR_ADMIN_SCOPE);
26+
return granted.has(OPERATOR_WRITE_SCOPE);
2727
}
2828
return granted.has(requestedScope);
2929
}

0 commit comments

Comments
 (0)