Repository navigation
fix(setup): 收窄默认飞书 user 桶文档权限 - #3794
Merged
Merged
Conversation
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 24, 2026 09:25
tenant 文档与评论权限全部保留,避免把 agent 经 lark-cli 使用的应用身份能力误判为死权限。user 桶仅移除可由 comment:write_only 覆盖的评论更新细粒度项,以及无内置用户工作流、可按需申请的文档块转换项。补充双桶防回归与老 Bot 历史授权不被清理的测试。 Co-Authored-By: Kimi <[email protected]>
deepcoldy
force-pushed
the
wt/botmux-bot-src-setup-lark-scopes
branch
from
November 24, 2026 15:44
88e5bb0 to
c6e2836
Compare
Owner
Author
评审意见(head
|
将移出默认 user 桶的评论更新与文档块转换权限登记到 EXTRA_USER_SCOPES,使老应用和 extra-scopes 用户无需 allowUnknown 即可继续授权;不加入 ON_DEMAND_USER_SCOPES,避免续权丢弃既有授权。补充名称校验、auth-request 与错拼拒绝回归。 Co-Authored-By: Kimi <[email protected]>
|
🚀 Released in v3.59.33 |
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.
背景与收窄原则
飞书企业租户新建 Bot 时,权限清单中只要有一项命中人工审核,整个应用版本可能一起停在「需要企业管理员审核」,且不指出具体权限,阻塞 Bot 注册/上线。
本 PR 按最新验收边界收窄默认清单:
src运行时零调用就删权限。 tenant(应用身份)权限会被 agent 通过 lark-cli 用于文档读写、回复/管理文档评论等场景。im:resource「默认不申请、用到时单独授权」模式一致;调用方也可用 feat(setup): setup add/configure 支持 --extra-scopes-file 追加权限清单 #2662 的--extra-scopes-file追加应用声明。两项同时登记在EXTRA_USER_SCOPES,老应用及按需授权无需allowUnknown。保留项若仍被特定租户判为需审,由 feat(setup): 飞书开放平台卡审批时草稿态自动二分避开需审权限 #3758 在草稿态自动避审并给出按需开通入口。最终相对 master 只删除 user 桶 2 行:
docs:document.comment:update与docx:document.block:convert。tenant 桶不变。逐项核实结论
contact:contact.base:readonlyGET /contact/v3/users/:id;lark-clicontact +get-user也支持 bot/user 两种身份。飞书「获取单个用户信息」把该项列为 API 调用权限;contact:user.base:readonly是姓名等字段权限,不能替代调用权限。docs:document.comment:create/watch-comment回复/新建文档评论;user:旧/subscribe-lark-doc通过DOC_COMMENT_OAUTH_SCOPES专项 OAuth 获取。中英文功能文档与启动文档就绪检查均引用。docs:document.comment:deletedrive +delete-reply --as bot等文档评论管理流程使用。虽然接口也接受comment:write_only,按新准则不再以“有替代权限/原生零调用”为由删除 tenant 项。docs:document.comment:updatedocs:document.comment:write_only,而该权限仍在 user 桶,因此这个细粒度 user 项是冗余的。docx:document.block:convertdocs +create/+update(XML 与 Markdown)--dry-run均走docs_ai创建/更新端点。--extra-scopes-file声明并按需授权。该项已加入EXTRA_USER_SCOPES,授权无需--allow-unknown;tenant 不变。docx:document:write_only/login --scope docx:document:write_only也有既有行为测试。飞书「更新块的内容」接受它作为原生 Docx 写权限。application:bot.basic_info:read是开启机器人能力时飞书自动携带的权限,本来就不在这份清单中,本次不改。评论权限的外部兼容性核实只使用 lark-cli 1.0.98 的
schema/--dry-run;没有执行真实文档或评论写操作。对新 Bot 与老 Bot 的影响
docs:document.comment:update、docx:document.block:convert两项。其它候选权限及文档能力保留。保留项仍可能因租户策略需审,命中时由 feat(setup): 飞书开放平台卡审批时草稿态自动二分避开需审权限 #3758 自动避审,不承诺所有版本都自动通过。BOTMUX_REQUIRED_SCOPES和已启用功能的专用清单计算「缺失项」,不会拿缩短后的默认清单反向差集清理额外授权。EXTRA_USER_SCOPES,/login --scope和botmux auth request均无需--allow-unknown。它们没有加入ON_DEMAND_USER_SCOPES,所以续权不会把老 token 里已有的这两项当成按需权限丢弃。comment:update的替代comment:write_only仍是默认 user 权限。回归测试
comment:delete。contact.base、comment:create、comment:write_only、docx:write_only和核心消息权限,避免读空清单或误删实际功能也让测试通过。allowUnknown即可通过纯函数检查与真实auth-request路由,错拼名仍拒绝;另钉住两项不属于ON_DEMAND_USER_SCOPES,防止续权丢老授权。EXTRA_USER_SCOPES前,新用例 3 项失败(两个名称检查及auth-request400);补入后全部通过,错拼拒绝与续权分类保持正确。实际执行:
按要求未部署、未重启 daemon/fleet,未修改线上
bots.json,未变更任何真实飞书应用的权限或版本;全量测试交由 CI。🤖 Generated with Claude Code