skillhub/docs/skill-visibility.md
小妍儿 ✨ 3ee80f996b
feat(auth): split API token skill capabilities (#1049) (#1078)
* docs(openspec): propose split API token skill capabilities

Define five token capabilities (read, submit, publish-private, manage,
delete), the route mapping, combined-operation limits, token minting
limits, legacy token and CLI compatibility, and negative test design.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <xiaoyaner0201@users.noreply.github.com>

* docs(openspec): clarify token compatibility and bundle snapshot boundaries

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* docs(auth): inventory Bundle authorization provenance

Record persisted evidence and fail-closed recovery rules before implementing snapshots.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* feat(auth): split token capabilities and classify route policies

Preserve Suite deletion authorization and verify legacy route compatibility against the original ordered catalog.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* feat(auth): enforce token ceilings on combined skill operations

Persist Bundle initiator capability snapshots and fail closed on unknown historical authority during recovery and retry.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* feat(auth): bound token issuance and expose effective capabilities

Validate requested scopes and expiry before rotation or extension. Expose capability discovery and machine-readable authorization errors without broadening token privileges.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* feat(tokens): add Web capability presets and CLI authorization guidance

Issue candidate-only login tokens, display effective capabilities and legacy compatibility, and require explicit delete authorization without automatic reissuance. Verify real HTTP candidate and legacy publication flows.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* docs(auth): document token capabilities and upgrade boundaries

Describe bounded issuance, compatibility aliases, CLI delete authorization, administrator upload changes, fail-closed Bundle recovery and the omitted-scopes deprecation schedule.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* docs(auth): align capability action boundaries

Document manage authorization for review withdrawal and keep DTO imports formatted with backend conventions.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* fix(publish): limit visibility ceiling check to token calls

Session uploads keep their previous path, and a missing locked row no longer raises a null pointer before the existing visibility checks run.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* fix(auth): preserve rerelease ceilings and explain bundle blocks

Carry token capabilities through rerelease and resolve visibility under the publication lock. Localize permanent Bundle authorization failures and hide ineffective retry actions.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* fix(auth): classify main's public routes and renumber bundle snapshot migration

main added public GET site-presentation routes and its own V122 migration. Record the new routes in the catalog baseline as unchanged public routes and move the Bundle authorization snapshot to V123.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* test(site): pin presentation upgrade check to V122

The upgrade test counted every migration after V121; with the Bundle snapshot now at V123 it saw two. Target V122 so it keeps checking only the presentation seed.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* fix(auth): compare token expiry ceilings at stored precision

Token expiry is stored at microsecond precision. On Linux CI Instant.now() carries nanoseconds, so a child token asking for exactly its parent's expiry compared as later and was rejected. Truncate requested expiry to microseconds before the ceiling check.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* fix(auth): renumber bundle snapshot migration after main's V123

main 22409aba added V123__homepage_recommendations. Move the Bundle authorization snapshot to V124 and record main's public site-recommendations routes in the token catalog baseline as unchanged public routes.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* test(auth): keep built-in skill sync out of token flow side-effect checks

Since main 22409aba the built-in skill sync can publish after startup, asynchronously, and its storage writes landed inside the 'denied rerelease writes nothing' assertion on CI. Disable built-in sync for this test class, as other integration tests already do.

Refs #1049

Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>

* fix(auth): block bundle recovery with unknown authorization

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
(cherry picked from commit cb8fb05d77d4b455032cbc2d3a1fdc2dd7bce894)
Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

* feat(web): redesign token credentials and compact permission controls

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
(cherry picked from commit acd3615ee57a4bb432980601bb883a1a86906d1a)
Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

* chore(web): regenerate API types from integrated backend

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

* fix(web): complete token locales and static analytics markers

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

* test(auth): preserve operation-level bundle authorization errors

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>

---------

Signed-off-by: 千乘妍 (Xiaoyaner) <xiaoyaner0201@users.noreply.github.com>
Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>
Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
Co-authored-by: 千乘妍 (Xiaoyaner) <xiaoyaner0201@users.noreply.github.com>
Co-authored-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
2026-11-16 11:02:38 +08:00

55 lines
4.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 修改已发布技能的可见范围
适用于已发布技能。这个操作保留原技能的标识、ZIP 内容、版本号、评分和下载统计,不需要重新上传包。
## 在哪里操作
1. 打开「我的技能」。
2. 找到已发布且正常的技能,点击「可见范围」。空间管理员也可在有维护权限的技能详情页「生命周期管理」中操作。
3. 选择目标范围,阅读页面提示后保存或提交审核。
技能所有者、所在空间 OWNER/ADMIN 和超级管理员可以操作。普通成员不能调整他人的技能。冻结、归档空间中的技能和隐藏、归档或没有已发布版本的技能不支持此操作。
| 当前范围 | 目标范围 | 处理方式 |
|---|---|---|
| 公开 | 空间成员可见、私有 | 立即生效 |
| 空间成员可见 | 私有 | 立即生效 |
| 私有 | 空间成员可见、公开 | 提交审核 |
| 空间成员可见 | 公开 | 提交审核 |
私有并不代表平台无法治理:技能所有者、拥有相应空间权限的管理员以及现有超级管理员访问规则仍然适用。
## 列表中的当前范围和申请进度
「我的技能」会同时说明当前生效范围和待审目标,例如「当前范围:私有」以及「申请公开 · 审核中,批准前保持当前范围」。申请提交后刷新页面,仍可看到这项说明;批准、拒绝或撤回后,待审说明消失。申请公开不等于已经公开。「待审核」筛选同时包含待审内容版本和待审范围申请;同一技能只列一次,范围申请结束后退出该筛选(仍有待审内容版本时继续保留)。
私有技能不出现在技能市场,包括所有者自己的私有技能;请在「我的技能」管理。
已提升的团队技能仍保留,同时存在独立的全局副本。「我的技能」分别标明「团队来源」和「全局副本」,有权查看时提供互相跳转入口。团队来源再次提交时使用「更新全局版本」;两条技能的版本和统计仍各自独立,不会自动同步。
## 扩大范围后的审核
- 批准前仍按原范围访问;不提前出现在目标受众的搜索或下载结果中。
- 使用现有「我的审核进度」和空间/平台「技能审核」入口,不增加第二套审核队列。审核详情会显示原范围、目标范围和扫描状态。
- 如果发布包已有可复用的安全通过结果,复用该结果;否则直接扫描已存储的发布包,不要求上传新的版本。扫描进行中、失败或未通过时不能批准,原范围不变。
- 需要扫描而部署方未开启安全扫描器时,本次提交失败,原范围不变。头像机器审核开关不是技能包扫描器开关。
- 有自定义头像时,按目标受众重新执行现有头像规则,并绑定同一技能审核申请。
- 审核拒绝不改变原范围。申请人可在「我的审核进度」撤回;扫描失败后可撤回重试,内容有问题时应上传修复版本。
- 当前技能内容审核没有可关闭的全员直发配置;独立扩大范围沿用该审核行为。头像人工审核开关不会关闭技能范围审核。
存在待审内容版本、正在扫描的待发布版本、待审头像或待审范围申请时,应先完成或撤回,再提交另一项操作。上传接口同样会检查待审范围申请。待审范围期间也不能另提交头像,避免覆盖已绑定的审核内容;单改头像之间仍按原规则允许新申请替换旧申请。
## API 接入
Web 使用 `/api/web`;外部客户端使用 `/api/v1`。两者支持相同的路径:
- `GET /skills/{namespace}/{slug}/visibility`:维护者读取当前范围及待审核目标。
- `POST /skills/{namespace}/{slug}/visibility`:提交 `{"visibility":"PUBLIC"}`、`NAMESPACE_ONLY` 或 `PRIVATE`。
响应 `data` 包含 `visibility`(当前生效范围)、`requestedVisibility`(待审核范围,无则为 null)和 `reviewTaskId`(申请编号,无则为 null)。不能把 `requestedVisibility` 当作已生效范围。
会话调用继续遵守 CSRF;API Token 写入需要 `skill:manage`,服务端仍检查技能维护权限。
旧 `skill:publish` 别名包含 manage;read + submit 不包含。上传改变已有技能可见性同样需要 manage,
拒绝发生在创建版本之前。重复申请和过期审批返回业务冲突,现有统一审核接口负责审批与撤回。
已下载到用户电脑的文件无法通过缩小范围收回;后续详情和下载接口的新请求按新范围检查。已签发的对象存储预签下载地址在原有效期内仍可能可用(当前 `SkillDownloadService.buildDownloadResult` 使用 `Duration.ofMinutes(10)`);改变范围不会撤销已签发地址。搜索索引在事务提交后异步重建,服务端仍以当前技能权限为准。