api-server/docs/issues/API-OPS-001-missing-production-env-keys.md
wangdl 1ed86b3ab3
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 45s
docs: add API-OPS-001 missing production env keys issue
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 15:38:48 +08:00

43 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# API-OPS-001: 生产环境缺少 INTERNAL_API_KEY 和 CREDENTIAL_ENCRYPTION_KEY
## 基本信息
| 字段 | 值 |
|------|-----|
| Issue ID | API-OPS-001 |
| 类型 | Ops / 配置遗漏 |
| 仓库 | api-server + devops-projects |
| 优先级 | P1 - 阻塞 Heavy Runtime 部署 |
| 发现日期 | 2026-06-18 |
## 问题描述
8C32G 生产服务器120.53.227.155)的 `/opt/zhixi/env/.env.production` 缺少两个必需环境变量:
| 缺失变量 | 用途 | 当前回退 |
|----------|------|----------|
| `INTERNAL_API_KEY` | Heavy Runtime 调用 Internal API 的鉴权 token | 回退到 `RAG_WORKER_SECRET`(安全边界模糊) |
| `CREDENTIAL_ENCRYPTION_KEY` | AES-256-GCM 用户 API Key 加密 | 未配置会导致加密/解密失败 |
## 后果
1. **INTERNAL_API_KEY**:当前 InternalAuthGuard 回退到 RAG_WORKER_SECRET但这是设计缺陷——RAG Worker 和 Heavy Runtime 应使用独立 token
2. **CREDENTIAL_ENCRYPTION_KEY**:用户绑定 DeepSeek Key 时加密会失败getEncryptionKey() 抛 "CREDENTIAL_ENCRYPTION_KEY not configured"
## 修复方案
`.env.production` 中添加:
```env
INTERNAL_API_KEY=<生成32位随机字符串>
CREDENTIAL_ENCRYPTION_KEY=<生成32字节密钥>
```
并同步更新 docker-compose.yml 中 heavy-runtime 服务的 `RUNTIME_SERVICE_TOKEN` 指向 `INTERNAL_API_KEY`
## 相关文件
- `devops-projects/凭据配置/蜂驰云服务器凭据.md` — 更新环境变量清单
- `api-server/docker-compose.yml` — 已正确定义(需同步到生产 env
- `zhixi-heavy-runtime/docs/operations-manual.md` — 已文档化 `RUNTIME_SERVICE_TOKEN`