feat: implement frontend-backend encrypted communication via AES-256-GCM
参考 novavis-authority 的加解密方案,实现前后端通信的应用层加密: - 重写 src/lib/crypto.ts 使用 Web Crypto API(浏览器兼容),PBKDF2+AES-256-GCM - 新增 src/lib/crypto-server.ts 服务端加解密工具(Node.js crypto) - 新增 src/lib/api-crypto.ts API 路由中间件 withCrypto(),自动解密请求体/加密响应体 - 更新 src/lib/admin-api.ts 自动加密所有请求/解密响应 - 所有 11 个 admin API 路由文件已应用 withCrypto 包装器 - 更新 .env 文件,添加 NEXT_PUBLIC_ENCRYPTION_SECRET 和 ENCRYPTION_SECRET
This commit is contained in:
@@ -20,3 +20,10 @@ CMS_REVALIDATE_SECRET=change-me-in-production-min-32-bytes
|
||||
|
||||
# CDN 配置(可选)
|
||||
CDN_DOMAIN=
|
||||
|
||||
# 前后端通信加密密钥(生产环境必须替换为高强度随机字符串,不得低于 12 字符)
|
||||
# 前端: NEXT_PUBLIC_ENCRYPTION_SECRET 编译时注入,后端: ENCRYPTION_SECRET 运行时环境变量
|
||||
# 前后端值必须保持一致,否则加解密会失败
|
||||
# 可使用 openssl rand -base64 32 生成
|
||||
NEXT_PUBLIC_ENCRYPTION_SECRET=change-me-in-production-min-12-chars
|
||||
ENCRYPTION_SECRET=change-me-in-production-min-12-chars
|
||||
|
||||
Reference in New Issue
Block a user