Skip to content

fix(czdev): 修复 403 权限校验并改为包名先到先得的所有权模型#14

Merged
eggfly merged 1 commit into
mainfrom
fix/czdev-permission-and-ownership
Jul 21, 2026
Merged

fix(czdev): 修复 403 权限校验并改为包名先到先得的所有权模型#14
eggfly merged 1 commit into
mainfrom
fix/czdev-permission-and-ownership

Conversation

@eggfly

@eggfly eggfly commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

背景

同事用 czdev publish 上传 deb 时报错:

Error: permission status
Caused by:
  HTTP status client error (403 Forbidden) for url
  (.../repos/CardputerZero/packages/collaborators/<user>/permission)

根因:check_permission 调用的 GET /repos/{owner}/{repo}/collaborators/{username}/permission 端点要求调用者本身对该仓库有 push 权限,外部贡献者没有权限时返回 403(而非 404),代码只处理了 404,导致本该"fork + PR"的分支永远走不到。

改动

  • 修复权限判断(方案 B):改用 GET /repos/{owner}/{repo} 返回的 permissions 字段判断登录用户权限,任何能看到仓库的用户都能拿到,不需要 push 权限;403/404 一律视为无权限,正常进入 fork 流程。
  • 去掉 author 邮箱限制,改为「包名先到先得」:不再要求 deb 的 Maintainer 邮箱匹配上传者的 GitHub 验证邮箱。谁先上传某个包名,谁就是 owner;owner 以上传者的 GitHub login 为准,记录在 release manifest 的 uploaded_by / uploader_email 字段。
  • unpublish 按记录的上传者 login 判所有权(历史包无 uploaded_by 时,从旧 deb 的 Maintainer noreply 邮箱反推 login)。
  • 删除 Rust czdev 的发布二进制 workflowrelease-czdev.yml):发布链路统一走 Python,杜绝再分发带旧 publish 逻辑的 Rust 二进制。

配套 PR(跨仓库)

同一套所有权模型需要在服务端权威校验处同步(否则 CLI PR 仍会被 CI 拦):

  • CardputerZero/packagesvalidate-pr.yml
  • CardputerZero/dev-portal 的 Worker 与 packages-workflows/*

Made with Cursor

- check_permission: query `GET /repos/{owner}/{repo}` permissions instead of
  the collaborators/{user}/permission endpoint, which requires push access and
  returned 403 Forbidden for external contributors — breaking the intended
  fork+PR fallback (the "Error: permission status" failure).
- publish: stop requiring the deb Maintainer email to match the uploader's
  GitHub verified emails. Record the uploader (`uploaded_by` login +
  `uploader_email`) in the release manifest instead.
- unpublish: enforce ownership by the recorded uploader login (with a legacy
  fallback deriving the login from the binary's Maintainer noreply address)
  rather than email matching.
- remove the Rust czdev release workflow; publishing is Python-only now.

Co-authored-by: Cursor <cursoragent@cursor.com>
@eggfly
eggfly merged commit 6716c09 into main Jul 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant