3 Commits

Author SHA1 Message Date
xfy
c237007111 docs: add production deployment guide
服务端的安全逻辑(会话 Cookie Secure 标志、限流按真实客户端 IP 聚合、
CSRF origin 校验)都默认前置反向代理并终结 TLS,但缺少一份成体系的部署
文档说明这一点。不知情的部署者直接把 3000 端口暴露到公网 HTTP 会同时踩中
cookie 无 Secure、限流退化/可伪造、CSRF Host 回退可绕过三个坑。

新增 docs/DEPLOYMENT.md:
- 醒目的前置警告,禁止裸暴露 3000 端口到公网 HTTP
- nginx + Caddy 最小配置示例(含 XFF 覆写、body 上限对齐应用侧 10 MiB、
  代理超时对齐应用侧 300s)
- 生产环境必设变量三件套及 TRUSTED_PROXY_COUNT 设错的两种后果
- Docker 部署示例(绑定回环地址,反代作为唯一公网入口)
- 部署后验证清单

README 加「生产部署」节链接到该文档。代码无需修改——三个环境变量的保守
默认值与 .env.example 的警告注释设计上是正确的,缺口纯粹是文档。
2026-06-29 10:55:24 +08:00
xfy
449a545886 security: fix critical issues from repository review
Some checks failed
CI / build (push) Has been cancelled
CI / check (push) Has been cancelled
P0 blockers:
- Fix migration numbering conflict and duplicate indexes
- Change comments.post_id FK to ON DELETE CASCADE
- Restrict public post detail endpoint to published posts only
- Fix rate-limiting IP extraction and fallback to ConnectInfo
- Harden HTML sanitizer: deny unknown URL schemes, restrict data URIs
- Remove session token from login response body
- Enforce image pixel/dimension limits on upload and serving

P1 high-risk:
- Validate uploads by magic bytes and decode GIF/WebP
- Add pagination/rate-limiting to search, tag posts, and comments
- Make first-admin registration and slug uniqueness check atomic
- HTML-escape comment author fields
- Improve HTML minify cache key and skip admin/error responses
- Add mobile navigation menu

P2 accessibility/quality:
- Associate form labels with inputs
- Key PostDetail article by slug to re-init scripts on navigation
- Improve image viewer keyboard accessibility
- Make theme toggle SSR-friendly and add aria-label
- Invalidate slug 404 cache on create and pending count on new comment
- Deduplicate tags case-insensitively

P3 cleanup:
- Remove unused tower-http dependency, expand make clean
- Configure DB pool timeouts and verified recycling
- Run background cleanup tasks immediately on startup
- Use SHA-256 for stable disk cache keys
- Log DB errors with Display instead of Debug
- Update README migration instructions

All tests pass (321), clippy clean, dx check clean.
2026-06-17 10:34:14 +08:00
xfy
f3204e108b 添加项目 README
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 18:06:28 +08:00