Repository navigation
fix(auth): 委派路径用派单里已校验的 union_id 向平台取凭据 - #2376
Merged
Merged
Conversation
委派轮次(签名派单、委派定时任务)向中心化平台要凭据时,原先拿发起方 app 视角的 open_id(credentialOpenId)在接收方 app 里反查 union_id。open_id 按 app 划分,接收方查不到, platform 模式下委派轮次一律被拒,auto 模式只能退回本机登录态。 - DelegatedCliIdentity 带上派单记录里已校验的 unionId(委派定时任务取 authority 的 controlUnionId),resolvePlatformIdentity 接受直接传入的 unionId,不再查通讯录; 普通轮次照旧按发送者 open_id 查,本机凭据仍按发起方 open_id 取。 - 绑定会话的 lark-cli --as user 委派路径同样直接用这个 unionId。 - publishDelegated 平台没给凭据时:platform 模式直接拒绝、不查本机;auto 模式本机也没有 时显式拒绝。 - 起点是 #2171 的 06580c3。 Co-authored-by: s425557423 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
October 26, 2026 10:24
This was referenced Oct 26, 2026
|
🚀 Released in v3.53.0 |
deepcoldy
pushed a commit
to s425557423/botmux
that referenced
this pull request
Oct 28, 2026
…oldy#2376 取 turnId 修复已由 deepcoldy#2365 合入,auth 修复已由 deepcoldy#2376 合入;两处冲突取 master 实现, 合并后相对 master 只剩 botGrants。daemon.ts 中 master 新增的 until-done `done` 自管理动作与 bot-policy 话题收尾两者都保留。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
主 agent 把任务派给子 agent(签名派单
botmux dispatch,或委派建的定时任务)时,子 agent 那一轮按派单里的发起人取bytedcli/lark-cli凭据。凭据来源选「中心化平台」(credentialSource: platform,或auto且本机已绑定平台)时,这条委派路径一直拿不到平台凭据。起点是 #2171 的提交 06580c3(作者已同意交给维护者处理,本 PR 带上其署名)。按维护者的要求,本 PR 不再走「union_id → 接收方 open_id → 通讯录换回 union_id」这一圈,而是直接用派单里已经校验过的 union_id。
根因
credentialOpenId是发起人在发起方 bot 的 app 里的 open_id,targetOpenId是同一个人在接收方 bot 的 app 里的 open_id。open_id 按 app 划分,只在签发它的 app 里有效。publishDelegated向平台要凭据时,用的是接收方 bot 的 app 去解析credentialOpenId的 union_id。这在接收方 app 里查不到,平台查询返回「不可用」:platform模式下委派轮次一律被拒;auto模式只能退回本机登录态(要求这个人恰好在本机经发起方 bot 登录过)。targetOpenId反查也不可靠:接收方 bot 的通讯录范围通常不覆盖这个人,通讯录接口不可用时同样失败。dispatch-user-delegations.json,HMAC 签名,按 messageId 精确匹配)本来就带着发起人的 union_id,而且 daemon 已经校验过;委派定时任务的 authority 记录里也有controlUnionId,每次运行前由authorizeDelegatedScheduleRun在本 app 里重新解析校验。改了什么
src/core/turn-cli-identity.ts:DelegatedCliIdentity新增必填的unionId(派单记录里已校验的值)。publishDelegated向平台要凭据时直接用它,不做任何 open_id 查询。平台没给凭据时:platform模式直接显式拒绝,不读本机任何凭据;auto模式先看本机已有的登录(仍按发起方 open_id 取),也没有就显式拒绝。顺带更正平台查询上方「keyed by the issuer-scoped open_id」的旧注释。src/core/platform-credential-source.ts:resolvePlatformIdentity的入参改成二选一:普通轮次传发送者openId(照旧查 union_id);委派路径传已校验的unionId(原样使用,形状不对就当作不可用,不发给平台)。src/core/lark-tool-platform-credential.ts+src/core/dashboard-ipc-server.ts:绑定会话里lark-cli --as user的委派路径,向平台要凭据时同样直接用派单的unionId。src/daemon.ts:构造委派身份的两处补上unionId:delegation.authority.unionId;authority.controlUnionId(缺失时拒绝,与已有的credentialOpenId缺失处理一致)。test/turn-cli-identity-platform.test.ts里「The platform key must come from the former」的旧注释。另补用例:bytedcli和lark-cli经平台授权的委派;platform模式不碰本机;auto模式本机兜底和最终显式拒绝;影响面评估
local模式:不咨询平台,行为不变。auto模式:以前平台这一步必然失败、落到本机;现在平台能给就用平台凭据(与普通轮次同口径),给不了仍退回本机已有登录。platform模式:委派轮次以前一律被拒,现在能拿到平台凭据。triggerUserAuth的 bot:不发布身份、不写派单委派记录,不受影响。验证
变异(每处单独改回 bug,跑相关测试):
🤖 Generated with Claude Code