feat: v2.0.0 邮件接收架构改造 —— 移除 Node,Email Worker 直连 Console(docs/11)
- 两阶段接收:POST /internal/email/authorize(accept/reject/temporary_error)+ POST /internal/email/ingest(raw MIME 直传) - Worker-Console 协议:Authorization: WmailHub-Worker + timestamp/nonce/body-hash/HMAC,nonce 防重放,凭据撤销即时生效 - 数据模型:nodes/node_credentials -> cloudflare_accounts/worker_credentials(迁移 0003),emails/domains 归属 account_id - 接入流程 Connect Cloudflare Account:OAuth 自动同步域名 + 部署账号级 Email Worker + 签发 Worker 凭据;rotate 自动重部署 - 动态邮箱:创建/删除/禁用下一封邮件立即生效;拒绝码 DOMAIN_*/MAILBOX_*;超时/5xx 不伪装成邮箱不存在 - 删除 node/ 目录、旧 /api/internal/nodes 协议、ingress/enrollment 概念;dev.ts 简化为 console + email worker 双进程 - 前端:账号页 Email Worker/凭据管理,设置窗口移除默认 Ingress,仪表盘/文案同步;版本 2.0.0 - 测试 62 项全过(新增 authorize 决策矩阵 + Worker 两阶段临时错误语义);本机虚拟 E2E 12 场景全通 - docs 00-10 同步改写;README 更新
This commit is contained in:
+25
-25
@@ -1,47 +1,47 @@
|
||||
# 安全设计
|
||||
# 安全设计(v2,docs/11 §18)
|
||||
|
||||
## 安全边界
|
||||
|
||||
```text
|
||||
Cloudflare Email Worker
|
||||
|
|
||||
| authenticated request
|
||||
v
|
||||
Node
|
||||
|
|
||||
| TLS + HMAC
|
||||
v
|
||||
Console
|
||||
Internet -> Cloudflare Email Routing -> Email Worker
|
||||
|
|
||||
| HTTPS + HMAC + timestamp + nonce + body hash
|
||||
v
|
||||
Console(/internal/email/*)
|
||||
```
|
||||
|
||||
公网不得直接调用 /internal/email/authorize 与 /internal/email/ingest:
|
||||
所有请求必须携带有效的 Worker credential 签名(docs/04)。
|
||||
|
||||
## Cloudflare OAuth
|
||||
|
||||
OAuth Token 加密存储,不进入前端和日志,也不作为 Node credential。
|
||||
OAuth Token 加密存储,不进入前端和日志,也不作为 Worker credential。
|
||||
|
||||
## Node Credential
|
||||
## Worker Credential
|
||||
|
||||
由 Console 自动生成。用户不手工配置。支持撤销和重新 enrollment。
|
||||
由 Console 在接入/部署时自动生成并注入 Worker 脚本,用户不手工配置。
|
||||
支持撤销(立即生效)与轮换(轮换后已配置域名自动重新部署)。
|
||||
|
||||
## 请求签名
|
||||
|
||||
所有 Node -> Console 请求必须签名,签名覆盖 method、path、timestamp、nonce、body hash,防止篡改和 replay。
|
||||
所有 Worker -> Console 请求必须签名,签名覆盖 method、path、timestamp、nonce、body hash,
|
||||
Console 校验 Worker ID、timestamp 窗口、nonce 防重放、body hash、HMAC、credential 状态与
|
||||
账号归属,防止篡改、重放与跨账号访问。
|
||||
|
||||
## Worker -> Node
|
||||
## 隐私与日志
|
||||
|
||||
Worker 使用 Node 专用 ingress secret。Worker 不应拥有 Console credential。
|
||||
- 禁止记录 Cloudflare OAuth token、Worker secret、Webhook key、Authorization header 和完整 MIME;
|
||||
- reject reason 不泄露内部信息(只返回固定文案);
|
||||
- 不向客户端泄露数据库内部错误。
|
||||
|
||||
## 最小权限
|
||||
## 附件与大小限制
|
||||
|
||||
Cloudflare OAuth 只申请业务所需权限。
|
||||
限制单文件大小、单邮件总大小、文件数量和 MIME header 大小,避免资源耗尽。
|
||||
|
||||
## 日志
|
||||
## SSRF
|
||||
|
||||
禁止记录 Cloudflare OAuth token、Node secret、Webhook secret、Authorization header 和完整邮件正文。
|
||||
|
||||
## 附件限制
|
||||
|
||||
限制单文件大小、单邮件总大小、文件数量和 MIME header 大小,避免资源耗尽。
|
||||
Webhook endpoint 校验禁止 localhost、私网、link-local、metadata endpoint 与 DNS rebinding。
|
||||
|
||||
## 数据保留
|
||||
|
||||
默认 Email TTL 为 1 天,过期自动删除。
|
||||
默认 Email TTL 为 1 天,过期自动删除;nonce/oauth state/delivery 均有清理路径。
|
||||
|
||||
Reference in New Issue
Block a user