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

推荐订阅源

Y
Y Combinator Blog
D
Docker
有赞技术团队
有赞技术团队
D
DataBreaches.Net
The GitHub Blog
The GitHub Blog
爱范儿
爱范儿
H
Help Net Security
美团技术团队
MyScale Blog
MyScale Blog
B
Blog RSS Feed
C
Check Point Blog
Microsoft Security Blog
Microsoft Security Blog
阮一峰的网络日志
阮一峰的网络日志
A
About on SuperTechFans
小众软件
小众软件
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
GbyAI
GbyAI
G
Google Developers Blog
月光博客
月光博客
Google DeepMind News
Google DeepMind News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | 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
feat: generalize message access groups (#75813) · opencla...
steipete · 2026-05-02 · via Recent Commits to openclaw:main

@@ -1,70 +1,63 @@

1+

import {

2+

ACCESS_GROUP_ALLOW_FROM_PREFIX,

3+

parseAccessGroupAllowFromEntry,

4+

resolveAccessGroupAllowFromMatches,

5+

type AccessGroupMembershipResolver,

6+

} from "openclaw/plugin-sdk/command-auth";

17

import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";

28

import { logVerbose } from "openclaw/plugin-sdk/runtime-env";

39

import type { RequestClient } from "../internal/discord.js";

410

import { canViewDiscordGuildChannel } from "../send.permissions.js";

5116-

export const DISCORD_ACCESS_GROUP_PREFIX = "accessGroup:";

12+

export const DISCORD_ACCESS_GROUP_PREFIX = ACCESS_GROUP_ALLOW_FROM_PREFIX;

713814

export function parseDiscordAccessGroupEntry(entry: string): string | null {

9-

const trimmed = entry.trim();

10-

if (!trimmed.startsWith(DISCORD_ACCESS_GROUP_PREFIX)) {

11-

return null;

12-

}

13-

const name = trimmed.slice(DISCORD_ACCESS_GROUP_PREFIX.length).trim();

14-

return name.length > 0 ? name : null;

15+

return parseAccessGroupAllowFromEntry(entry);

1516

}

161717-

export async function resolveDiscordDmAccessGroupEntries(params: {

18-

cfg?: OpenClawConfig;

19-

allowFrom: string[];

20-

sender: { id: string };

21-

accountId: string;

18+

export function createDiscordAccessGroupMembershipResolver(params: {

2219

token?: string;

2320

rest?: RequestClient;

24-

}): Promise<string[]> {

25-

const names = Array.from(

26-

new Set(

27-

params.allowFrom

28-

.map((entry) => parseDiscordAccessGroupEntry(entry))

29-

.filter((entry): entry is string => entry != null),

30-

),

31-

);

32-

if (names.length === 0 || !params.cfg?.accessGroups) {

33-

return [];

34-

}

35-36-

const matched: string[] = [];

37-

for (const name of names) {

38-

const group = params.cfg.accessGroups[name];

39-

if (!group) {

40-

continue;

41-

}

21+

}): AccessGroupMembershipResolver {

22+

return async ({ cfg, name, group, accountId, senderId }) => {

4223

if (group.type !== "discord.channelAudience") {

43-

continue;

24+

return false;

4425

}

4526

const membership = group.membership ?? "canViewChannel";

4627

if (membership !== "canViewChannel") {

47-

continue;

28+

return false;

4829

}

49-

const allowed = await canViewDiscordGuildChannel(

50-

group.guildId,

51-

group.channelId,

52-

params.sender.id,

53-

{

54-

cfg: params.cfg,

55-

accountId: params.accountId,

56-

token: params.token,

57-

rest: params.rest,

58-

},

59-

).catch((err) => {

60-

logVerbose(

61-

`discord: accessGroup:${name} lookup failed for user ${params.sender.id}: ${String(err)}`,

62-

);

30+

return await canViewDiscordGuildChannel(group.guildId, group.channelId, senderId, {

31+

cfg,

32+

accountId,

33+

token: params.token,

34+

rest: params.rest,

35+

}).catch((err) => {

36+

logVerbose(`discord: accessGroup:${name} lookup failed for user ${senderId}: ${String(err)}`);

6337

return false;

6438

});

65-

if (allowed) {

66-

matched.push(`${DISCORD_ACCESS_GROUP_PREFIX}${name}`);

67-

}

68-

}

69-

return matched;

39+

};

40+

}

41+42+

export async function resolveDiscordDmAccessGroupEntries(params: {

43+

cfg?: OpenClawConfig;

44+

allowFrom: string[];

45+

sender: { id: string };

46+

accountId: string;

47+

token?: string;

48+

rest?: RequestClient;

49+

isSenderAllowed?: (senderId: string, allowFrom: string[]) => boolean;

50+

}): Promise<string[]> {

51+

return await resolveAccessGroupAllowFromMatches({

52+

cfg: params.cfg,

53+

allowFrom: params.allowFrom,

54+

channel: "discord",

55+

accountId: params.accountId,

56+

senderId: params.sender.id,

57+

isSenderAllowed: params.isSenderAllowed,

58+

resolveMembership: createDiscordAccessGroupMembershipResolver({

59+

token: params.token,

60+

rest: params.rest,

61+

}),

62+

});

7063

}