feat: add verified profile import and export
This commit is contained in:
@@ -298,6 +298,7 @@ gateway 运行时只负责 API 与静态文件服务,不再把复杂 UI 硬写
|
||||
- `usage` 中的 input / output / total / reasoning tokens
|
||||
- 分别管理文本 profiles 与图片 profiles
|
||||
- 各自新建 / 编辑 / 探测 / 切换 / 删除 profile env
|
||||
- 各自导出 / 导入可移植 profile JSON;导出前必须再次验证该 profile 当前实际使用的 API key
|
||||
- 文本切换 provider `base_url` 不会改写图片分流,图片切换只影响 `/images/*` 与 `/v1/images/*`
|
||||
- 各自切换 `passthrough` / `manual_bearer` / `fixed_bearer` / `auth_json` 认证模式
|
||||
- 改 `reasoning_equals`
|
||||
@@ -319,9 +320,25 @@ gateway 运行时只负责 API 与静态文件服务,不再把复杂 UI 硬写
|
||||
- 请求历史只记录元数据、请求体字节数和 token usage,不保存请求正文或响应正文;默认展示最近 200 条
|
||||
- gateway 日志持久化到 `~/.codex-retry-gateway/logs/gateway.log`
|
||||
- 请求记录持久化到 `~/.codex-retry-gateway/logs/requests.jsonl` 与 `~/.codex-retry-gateway/logs/requests.sqlite`,重启后会用于 UI 请求页以及 overview 的累计 token / reasoning 统计
|
||||
- `manual_bearer` 的手动 token/password 只写入系统 secret 文件,API/UI 不读回明文;profile env 只保存 secret 文件路径
|
||||
- `manual_bearer` 的手动 token/password 只写入系统 secret 文件,普通 profile API/UI 不读回明文;只有再次验证当前 key 的显式导出接口会把它放进下载文件,profile env 仍只保存 secret 文件路径
|
||||
- 其他 profile env 不保存明文 `sk-...`;固定密钥请使用 env/file 引用,或用 `auth_json` 指向 `auth.json` 字段名
|
||||
|
||||
### Profile 导入与导出
|
||||
|
||||
文本与图片 profile 都支持从 Profiles 页面导出和导入:
|
||||
|
||||
- 文本接口:`POST /__codex_retry_gateway/api/profiles/export`、`POST /__codex_retry_gateway/api/profiles/import`
|
||||
- 图片接口:`POST /__codex_retry_gateway/api/image-profiles/export`、`POST /__codex_retry_gateway/api/image-profiles/import`
|
||||
- 导出前必须再次提交该 profile 当前实际使用的 API key;gateway 会从现有 `manual_bearer` secret 文件、`fixed_bearer` env/file 或 `auth_json` 解析当前 key,并做常量时间比对
|
||||
- `passthrough` 没有 profile-owned key,无法完成再次验证,因此拒绝导出
|
||||
- 验证成功后才返回 `codex-retry-gateway-profile` v1 JSON;文件包含明文 API key,文本 profile 若配置了管理 Access key 也会一并保留
|
||||
- 导出响应使用 `Cache-Control: no-store`,服务端不生成或保留导出副本,日志只记录 profile 名称和认证来源,不记录 key
|
||||
- 导入只接受该格式的 JSON,并把包内 key 写入目标用户的默认 secret 文件,目录权限为 `0700`、文件权限为 `0600`;profile env 仍只保存 secret 文件路径
|
||||
- 为避免当前控制链路被意外改写,导入不会自动切换 profile,也不允许直接覆盖当前活跃 profile;同名非活跃 profile 需要显式确认覆盖
|
||||
- 导入后的认证统一落为可移植的 `manual_bearer`;先用 profile 探针验证,再手动热切换
|
||||
|
||||
导出文件本身就是明文 secret 载体,不应提交到 Git、上传到普通日志或长期放在共享下载目录。
|
||||
|
||||
## 如何调整拦截条件
|
||||
|
||||
编辑:
|
||||
@@ -398,6 +415,7 @@ macOS / Linux: ~/.codex-retry-gateway
|
||||
- `node scripts/test-gateway-e2e.mjs`
|
||||
- 已通过
|
||||
- 验证 strict capture 下 `/responses` 生命周期不注入空事件,长流 delta 按序完整回放并以 `response.completed` 结束
|
||||
- 验证文本 / 图片 profile 导出必须重新校验 key,错误 key 不泄露 secret;导入后 key 只进入 `0600` secret 文件,不进入 profile env 或普通 API 响应
|
||||
- `test-install-restore.ps1`
|
||||
- 已通过
|
||||
- 验证安装、透传、UI 页面、热更新配置、实时日志、516 统计、恢复闭环
|
||||
|
||||
Reference in New Issue
Block a user