fix: 全面 QA 审计修复 — 安全加固/代码质量/跨平台一致性/测试覆盖
Phase 0 安全热修复 (CRITICAL): - 外部化微信 appid/secret 到 ERP__WECHAT__APPID/SECRET 环境变量 - 正确连接 HealthCrypto 到 ERP__HEALTH__AES_KEY/HMAC_KEY 环境变量 - 外部化小程序加密密钥到 TARO_APP_ENCRYPTION_KEY 环境变量 - 移除小程序 auth store 中的敏感信息 console.log Phase 1 安全加固: - 微信自动注册 display_name 添加 sanitize 防止 XSS - 测试数据库凭据改为从 TEST_DB_URL 环境变量读取 Phase 2 代码质量: - 提取 useThemeMode hook 消除 22 处重复暗色模式检测 - 提取共享健康常量到 constants/health.ts - 拆分 patient_service.rs 脱敏函数到 masking.rs - 移除未使用的 i18next/react-i18next 依赖 - 移除未使用的 api/errors.ts 和 erp-auth/anyhow 依赖 Phase 3 测试覆盖: - 新增 5 个患者模块集成测试 (CRUD/租户隔离/验证/软删除) Phase 4 跨平台一致性: - 统一小程序 Patient.birthday → birth_date 匹配后端 - 统一小程序 Appointment.time_slot → start_time/end_time 匹配后端 Phase 5 架构: - 微信登录添加多租户 TODO 注释 - 更新 wiki/infrastructure.md 环境变量文档
This commit is contained in:
@@ -35,6 +35,7 @@ tags: [infrastructure, dev-environment, windows, postgresql]
|
||||
| Redis 7 | `redis://:redis_KBCYJk@129.204.154.246:6379` (云端) | 缓存 + 限流 |
|
||||
| 后端 API | `http://localhost:3000/api/v1` | Axum 服务 |
|
||||
| 前端 SPA | `http://localhost:5174` | Vite 开发服务器 |
|
||||
| 微信小程序 | 微信开发者工具 | 患者端小程序(`apps/miniprogram/dist/`) |
|
||||
|
||||
### 登录凭据
|
||||
|
||||
@@ -52,8 +53,25 @@ psql: `D:\postgreSQL\bin\psql.exe -U postgres -h localhost -d erp`
|
||||
| `ERP__JWT__SECRET` | `dev-secret-key-change-in-prod` |
|
||||
| `ERP__AUTH__SUPER_ADMIN_PASSWORD` | `Admin@2026` |
|
||||
| `ERP__REDIS__URL` | `redis://:redis_KBCYJk@129.204.154.246:6379` |
|
||||
| `ERP__WECHAT__APPID` | `wx20f4ef9cc2ec66c5` |
|
||||
| `ERP__WECHAT__SECRET` | 微信小程序 Secret |
|
||||
| `ERP__HEALTH__AES_KEY` | 64 字符 hex 编码(32 字节) |
|
||||
| `ERP__HEALTH__HMAC_KEY` | 64 字符 hex 编码(32 字节) |
|
||||
|
||||
> 所有四个在 `default.toml` 中为 `__MUST_SET_VIA_ENV__` 占位符
|
||||
> 所有八个在 `default.toml` 中为 `__MUST_SET_VIA_ENV__` 占位符
|
||||
|
||||
> 开发环境 AES/HMAC 密钥生成: `python -c "import secrets; print(secrets.token_hex(32))"`
|
||||
|
||||
### 微信小程序配置
|
||||
|
||||
| 配置 | 位置 | 说明 |
|
||||
|------|------|------|
|
||||
| AppID/Secret | 环境变量 `ERP__WECHAT__APPID` / `ERP__WECHAT__SECRET` | 微信登录凭据 |
|
||||
| 加密密钥 | 环境变量 `TARO_APP_ENCRYPTION_KEY` | 小程序本地存储加密密钥 |
|
||||
| API URL | `apps/miniprogram/config/index.ts` `defineConstants` | 编译时注入,默认 `http://localhost:3000/api/v1` |
|
||||
| 开发者工具 | `apps/miniprogram/project.config.json` | `urlCheck: false`,AppID `wx20f4ef9cc2ec66c5` |
|
||||
|
||||
> 微信凭据和加密密钥通过环境变量注入,不硬编码在源码中
|
||||
|
||||
### 集成契约
|
||||
|
||||
@@ -62,6 +80,7 @@ psql: `D:\postgreSQL\bin\psql.exe -U postgres -h localhost -d erp`
|
||||
| 提供 → | [[erp-server]] | 数据库/Redis 连接 |
|
||||
| 提供 → | [[frontend]] | Vite 代理目标 |
|
||||
| 提供 → | [[testing]] | 测试环境配置 |
|
||||
| 提供 → | [[miniprogram]] | 后端 API + 微信登录 |
|
||||
|
||||
## 3. 代码逻辑
|
||||
|
||||
@@ -101,4 +120,6 @@ cd apps/web && pnpm install && pnpm dev
|
||||
|
||||
| 日期 | 变更 |
|
||||
|------|------|
|
||||
| 2026-04-25 | 外部化微信凭据和健康加密密钥为环境变量;添加 4 个新的必设环境变量 |
|
||||
| 2026-04-24 | 添加微信小程序配置信息和集成契约 |
|
||||
| 2026-04-23 | 重构为 5 节结构,确立为连接信息的单一真相源 |
|
||||
|
||||
Reference in New Issue
Block a user