feat(#182): 模型注册表后端化 TemplateRegistry 服务化 HTTP API(E1)
新增 core/model-framework/registry_api.py(标准库 http.server,对齐 auth_api
风格,零依赖),把已交付的 TemplateRegistry 暴露为 HTTP 服务:
- GET /api/v1/registry/models 列表(可按 stage 过滤)
- POST /api/v1/registry/models 注册新版本(服务端校验)
- POST /api/v1/registry/models/{name}/{version}/promote dev→staging→prod
- POST /api/v1/registry/models/{name}/rollback?version=&stage= 回滚指定 stage
服务端持久化:PersistedRegistry 每次写操作原子落盘到
deploy/data/registry/registry.json(可挂卷),重启不丢;首次启动自动播种
4 条演示模型(对齐 web/admin/admin.js seedModels)。
鉴权双轨:读接 FBA JWT(core/auth/fba_jwt.py),写要求权限码 iaop:admin
或 iaop:studio;未配置 FBA_TOKEN_SECRET_KEY 降级旧 core/auth 会话;
两者均无时为本地/CI 演示模式(读免鉴权、写需 token 占位)。
测试:tests/test_registry_api.py(16 例,含四接口回环联调、401/403 路径、
promote/rollback/持久化/种子)+ _fba_stub.py(FBA 桩)。全 284 例通过。
部署:deploy/fba/README.md 补 nginx 反代 /api/v1/registry/ → :8090 约定。
This commit is contained in:
@@ -150,3 +150,41 @@ docker exec -it fba_postgres psql -U postgres -d fba # 进数据库
|
||||
### 旧架构存档
|
||||
- `web/` 静态演示外壳保留(FBA 停掉时兜底;/index.html、/auth/login.html 已加 C1 自动收口跳转)
|
||||
- 旧登录页三轨会话已精简为 FBA 单轨(session.js,FBA 接入版)
|
||||
|
||||
---
|
||||
|
||||
## 模型注册表 API 反代(issue #182,PRD 5.3 ③)
|
||||
|
||||
iAOP 后端的模型模板注册表(`core/model-framework/registry_api.py`)以独立
|
||||
`http.server` 服务运行(默认 `127.0.0.1:8090`,零依赖标准库实现)。前端模型管理 /
|
||||
版本发布(E2,issue #183)通过 nginx 把 `/api/v1/registry/` 反代到该端口:
|
||||
|
||||
```
|
||||
location /api/v1/registry/ {
|
||||
proxy_pass http://127.0.0.1:8090/api/v1/registry/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
}
|
||||
```
|
||||
|
||||
服务启动:
|
||||
|
||||
```bash
|
||||
cd /opt/apps/iAOP
|
||||
# 配置 FBA 密钥后(与 fba.env 的 TOKEN_SECRET_KEY 一致)写操作接 FBA JWT 鉴权
|
||||
export FBA_TOKEN_SECRET_KEY=<同 fba.env>
|
||||
python -m core.model_framework.registry_api
|
||||
# → iAOP RegistryAPI on http://127.0.0.1:8090 (data=deploy/data/registry/registry.json, fba=on)
|
||||
```
|
||||
|
||||
数据落盘到 `deploy/data/registry/registry.json`(生产可挂卷),重启不丢。
|
||||
首次启动自动播种 4 条演示模型(与 `web/admin/admin.js` 的 `seedModels()` 对齐)。
|
||||
|
||||
鉴权双轨:读接口接 FBA JWT(`FbaAuth.verify`);写接口要求权限码 `iaop:admin` 或
|
||||
`iaop:studio`。未配置 `FBA_TOKEN_SECRET_KEY` 时降级旧 `core/auth` 会话(写权限由
|
||||
角色 admin/engineer 判定);两者均未配置时为本地/CI 演示模式——读免鉴权、写需
|
||||
带任意 token 占位(避免裸奔写)。
|
||||
|
||||
Reference in New Issue
Block a user