Skip to content

cardputer.cc 在线提交:网页直接上传 .deb(Cloudflare Worker + GitHub 联动)#11

Closed
eggfly wants to merge 1 commit into
mainfrom
cursor/cardputer-cc-upload-worker-2efb
Closed

cardputer.cc 在线提交:网页直接上传 .deb(Cloudflare Worker + GitHub 联动)#11
eggfly wants to merge 1 commit into
mainfrom
cursor/cardputer-cc-upload-worker-2efb

Conversation

@eggfly

@eggfly eggfly commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

背景

域名 cardputer.cc 已注册,"表单直接上传 deb"这条路打通了:文件 POST 到我们自己的 api.cardputer.cc(Worker 自己决定 CORS 头),与 GitHub 的所有交互都在 Worker 服务端完成,不受浏览器跨域限制。

架构

浏览器 (cardputer.cc/submit.html)
  ① GitHub OAuth 登录(空 scope,只读公开身份,不要仓库权限)
  ② POST /api/submit(multipart:.deb + 源码仓库 URL)
        ▼
Cloudflare Worker (api.cardputer.cc)
  ③ 魔数/大小/文件名检查 + 计算 sha256
  ④ 用 bot token 把 .deb 存入 packages 的 web-upload-buffer Release
  ⑤ repository_dispatch "web-submission"
        ▼
CardputerZero/packages Actions
  ⑥ 完整校验(与 validate-pr.yml 同规则:sha256、control、.desktop、
     Maintainer 邮箱必须匹配提交者、版本必须高于线上)
     + 克隆源码仓库读取 app-builder.json store 元数据与截图
  ⑦ 通过 → 自动开发布 PR 并 @提交者;失败 → 开 issue @提交者说明原因
        ▼
管理员审核合并 → 现有 apt-pool 提升 / 索引重建管线 → 上架

产物格式与 czdev publish 完全一致,两条通道并存、共用审核管线。

内容

  • online-submit/worker/ — Cloudflare Worker(OAuth 登录、HMAC 会话 cookie、收文件、转存 Release、触发 dispatch),无第三方依赖,wrangler deploy 即可
  • online-submit/packages-workflow/process-web-submission.yml — 复制到 CardputerZero/packages 的处理 workflow(已通过 yamllint/bash -n/内嵌 python 编译校验)
  • online-submit/site/submit.html — 提交页(登录 + 拖拽上传 + 结果反馈),复制到网站仓库即可用
  • online-submit/README.md — 中文部署指南(Cloudflare 接入、OAuth App、bot token、Pages 自定义域名)+ 安全设计说明 + OSS 直传的取舍分析

部署前提(需要人工操作)

  1. cardputer.cc 接入 Cloudflare(免费版),wrangler deploy + 4 个 secret
  2. 创建 GitHub OAuth App(callback https://api.cardputer.cc/auth/callback
  3. 一个对 CardputerZero/packages 有 Contents 写权限的 bot PAT
  4. workflow 和 submit.html 复制到对应仓库 —— 我目前对 CardputerZero/packagescardputerzero.github.io 仍无写权限(本轮实测依旧被拒),在 Cursor GitHub App 的 Repository access 里加上这两个仓库后我可以直接提 PR 落地

安全要点

  • 用户上传内容一律不可信:Worker 只做魔数/大小检查,语义校验全部在 Actions 里用 dpkg-deb 完成,.deb 永不执行
  • Maintainer 邮箱必须等于提交者的 noreply 或公开邮箱(与 czdev/PR 通道同规则),防冒名
  • dispatch payload 在 workflow 中只经 env 传递,防模板注入
  • Worker 不保存用户 OAuth token,会话为 HMAC 签名的 HttpOnly cookie(24h)
Open in Web Open in Cursor 

Direct .deb upload from the browser, enabled by the self-owned domain:
a Cloudflare Worker on api.cardputer.cc accepts POST uploads (CORS is under
our control, bypassing GitHub's uploads endpoint restriction), authenticates
developers via a zero-scope GitHub OAuth login, stores the binary in the
packages repo's web-upload-buffer release with a bot token, and fires a
repository_dispatch. A ready-to-copy workflow for CardputerZero/packages
runs the same validation as validate-pr.yml (sha256, control fields,
.desktop, maintainer email binding, version monotonicity), collects store
metadata from the developer's app-builder.json, and opens the publish PR
(or a feedback issue on failure). Includes the static submit page and a
Chinese deployment guide.

Co-authored-by: eggfly <lihaohua90@gmail.com>
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.

2 participants