fix(channel,user): owner 车道只认白名单,堵住群主/伪造 role 冒充主人(裁决 06.4.2/06.4.3/06.4.4)
- 适配器只描述平台身份:qq_obv11 的 owner/admin 一律上报 RoleMember,不再上报 RoleOwner - session 层唯一判主点只认白名单(owner.yaml Accounts ∪ 每渠道 adminIds),nil 档案 fail-closed 拒绝 - 新增「每渠道管理员层」:channels.json ChannelAccount.adminIds[] → runtimeconfig.AdminIDs → OwnerProfile.SetPlatformAdmins(整体替换语义,热重载后移除的 id 立即失效) - 组合根接线:启动即播种、面板保存先灌白名单再重载适配器(cmd/cyrene/wire_channels.go + 4 条端到端单测) - 06.4.3 节流与参与度状态按会话独立计数(ConversationKey 三处统一,空会话 GC);06.4.4 未知平台主动发言保守默认 1 条/分钟
This commit is contained in:
1 parent
7e7f53bb41
commit
af8591b78a
30 files changed
+1289
-144
No files matched your search
@@ -269,3 +269,32 @@ func accountBotToken(a config.ChannelAccount) string {
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// AdminIDs 汇总 channels.json 里各账号声明的管理员 id(裁决 06.4.2;design/08 §1.1、
|
||||
// design/11 §0),返回 platform → 去重后的管理员 id 列表(同一平台的多账号声明会合并去重、
|
||||
// 空串被丢弃)。**结果覆盖 accounts 里的每个平台**:未声明 adminIds 的平台对应空切片,
|
||||
// 这样 `for p, ids := range AdminIDs(accounts) { profile.SetPlatformAdmins(p, ids) }`
|
||||
// 就是一次整体替换——热重载后删掉的管理员 id 会立即失效(不会有悬挂管理员)。返回的切片是
|
||||
// 新建的,调用方改动它不影响 accounts。
|
||||
func AdminIDs(accounts map[string][]config.ChannelAccount) map[string][]string {
|
||||
out := make(map[string][]string, len(accounts))
|
||||
for platform, list := range accounts {
|
||||
seen := make(map[string]struct{})
|
||||
var ids []string
|
||||
for _, acct := range list {
|
||||
for _, id := range acct.AdminIDs {
|
||||
trimmed := strings.TrimSpace(id)
|
||||
if trimmed == "" {
|
||||
continue
|
||||
}
|
||||
if _, dup := seen[trimmed]; dup {
|
||||
continue
|
||||
}
|
||||
seen[trimmed] = struct{}{}
|
||||
ids = append(ids, trimmed)
|
||||
}
|
||||
}
|
||||
out[platform] = ids
|
||||
}
|
||||
return out
|
||||
}
|
||||
Reference in new issue
Block a user