Simon
|
a20606f328
|
fix(security): troubleshooting_templates 5 端点加 auth + MOCK 替换 ORM
P0 安全修复(连续 2 次巡检标记):
1. 5 端点全部加 auth 依赖
- GET list/detail → Depends(get_current_user)(任何已登录用户)
- POST/PUT/DELETE → Depends(require_admin)(仅 admin)
2. 进程内 MOCK_TEMPLATES → PostgreSQL troubleshooting_templates 表
- ORM model 早已注册但缺迁移 → 新建 057_troubleshooting_templates.py
- 8 套预设模板在冷启动时通过 seed_default_troubleshooting_templates 插入
- 容器重启不再丢数据
3. 5 源调用方审计通过(与 voice_asr.py P0 修复同款教训):
- H5 端 api/troubleshooting-templates.ts:只读
- Admin 端 api/troubleshooting.ts + Flowcharts.vue:5 端 CRUD 全套
- Agent 端 api/troubleshooting.ts:只读
- service_routes.py:仅注册无反向调用
- tests:无相关调用
4. 端到端验证(生产环境实测):
- GET no-auth → 403
- GET invalid-token → 401
- GET admin token → 200 + 8 items
- POST admin (sxn) → 201 + 新建 UUID
- POST 非 admin → 拒绝(业务 code 1002)
- PUT/DELETE admin → 200 + 字段更新/删除
- 容器重启后 → 8 套数据仍在(DB 持久化生效)
文件改动:
- alembic/versions/057_troubleshooting_templates.py(新建, 79 行)
- app/api/troubleshooting_templates.py(重写 720→859 行)
- app/main.py(1071→1082, +11 行 seed 调用)
相关 P1 跟进(已同步滴答清单):
- 053-056 迁移脱节(生产 alembic_version=052)
- 缺 2 索引 idx_tpl_category / idx_tpl_active
Refs: voice_asr.py P0 修复(5 来源审计教训)
|
2026-08-03 16:27:10 +08:00 |
|
Simon
|
b321e3dabd
|
chore(repo): 重组项目源码目录至 src/ 下 (#重组)
- 顶级源码目录 backend/ frontend-h5/ frontend-admin/ frontend-terminal/ frontend-agent/ 物理移动到 src/ 下
- frontend-agent/ HEAD 中原本只跟踪 dist 备份和零散配置(无业务源码),本次作为新模块首次纳入
- 强化 .gitignore: 覆盖历史 dist 备份(dist.bak/ dist_bak*/ dist-clean/ dist_old/ 等)、node_modules_old/、前端部署 bin chunk(*-part*.bin / p[0-9].bin)、src/backend/uploads/ + src/backend/media/(运行时上传)
- 备注: docs/ 目录重组(01-产品设计→01-产品文档 等)暂留 working tree,本次未入库
|
2026-08-03 15:42:28 +08:00 |
|