docs(plan): tighten token authority contract

Record the OpenAPI vs canonical principal gap, add tenant_id to the introspection response contract, and make the gateway README explicit that non-dev environments must use remote introspection.
This commit is contained in:
Your Name
2026-04-21 08:01:07 +08:00
parent 46152f50fd
commit b864a4ef1b
4 changed files with 23 additions and 5 deletions

View File

@@ -35,5 +35,14 @@ rg -n "inmemory|remote_introspection|token runtime|JWT|Bearer" gateway supply-ap
## P1-A-04 OpenAPI 与 canonical principal 差异记录
执行
执行命令:
```bash
rg -n "IntrospectTokenResponse|tenant_id|project_id|operator_id|metadata|IssueTokenRequest" docs/platform_token_api_contract_openapi_draft_v1_2026-03-29.yaml
```
结论:
1. `IssueTokenRequest` 已定义 `metadata`,但 `IntrospectTokenResponse.data` 尚未暴露 `tenant_id`
2. 现有 introspection 响应字段只有 `token_id``subject_id``role``status``scope``issued_at``expires_at`,与 canonical principal 最小字段清单相比缺少 `tenant_id`
3. `project_id``operator_id``metadata` 目前也未出现在 introspection 响应中,但它们尚未进入最小 canonical principal 强制字段,保留为 Phase 1 后续 schema / 审计收敛项。

View File

@@ -200,11 +200,11 @@
完成标准:文档里明确写出 authority 所属服务。
- [x] `P1-A-03` 在同一文档新增 canonical principal 字段清单。
完成标准:至少包含 `token_id``subject_id``tenant_id``scope``issued_at``expires_at``status`
- [ ] `P1-A-04` 打开 `docs/platform_token_api_contract_openapi_draft_v1_2026-03-29.yaml`,比对现有 introspection 响应字段。
- [x] `P1-A-04` 打开 `docs/platform_token_api_contract_openapi_draft_v1_2026-03-29.yaml`,比对现有 introspection 响应字段。
完成标准:差异项被记录到计划执行日志。
- [ ] `P1-A-05` 在 OpenAPI 草案里补 canonical principal 字段定义。
- [x] `P1-A-05` 在 OpenAPI 草案里补 canonical principal 字段定义。
完成标准OpenAPI 草案与最小规范字段一致。
- [ ] `P1-A-06``gateway/README.md` 增加“非 dev 环境只允许远程 introspection”说明。
- [x] `P1-A-06``gateway/README.md` 增加“非 dev 环境只允许远程 introspection”说明。
完成标准README 不再给 staging/prod 留下本地 authority 的解释空间。
- [ ] `P1-A-07``supply-api/README.md` 增加“消费统一 principal不自持独立 authority”说明。
完成标准README 用词与 Phase 1 目标一致。

View File

@@ -369,12 +369,14 @@ components:
type: string
data:
type: object
required: [token_id, subject_id, role, status, scope, issued_at, expires_at]
required: [token_id, subject_id, tenant_id, role, status, scope, issued_at, expires_at]
properties:
token_id:
type: string
subject_id:
type: string
tenant_id:
type: string
role:
type: string
enum: [owner, viewer, admin]

View File

@@ -10,6 +10,7 @@
- 鉴权运行时支持两种模式:
- `inmemory`
- `remote_introspection`
- `inmemory` 只允许用于 `dev` 本地联调;非 `dev` 环境必须使用 `remote_introspection`,不得在 `gateway` 本地承载 token authority。
- provider 注册已经从配置装配;如果未显式配置 provider启动时会基于环境变量生成默认 OpenAI provider。
- 审计发射器支持 PostgreSQL 与内存实现;数据库未配置时会显式回退到内存实现。
- 生产环境必须显式提供 `PASSWORD_ENCRYPTION_KEY``GATEWAY_CORS_ALLOW_ORIGINS`;缺省密钥和 `*` CORS 只允许在开发态使用。
@@ -39,6 +40,12 @@ export GATEWAY_TOKEN_RUNTIME_MODE="remote_introspection"
export GATEWAY_TOKEN_RUNTIME_URL="http://127.0.0.1:18081"
```
`dev` 环境约束:
1. `GATEWAY_ENV` 只要不是 `dev``GATEWAY_TOKEN_RUNTIME_MODE` 就必须设置为 `remote_introspection`
2. `staging``production` 和其他共享环境不得使用 `inmemory`
3. token 生命周期、状态解释和 introspection 字段以 `platform-token-runtime` 为单一真源。
默认监听 `0.0.0.0:8080`
生产环境额外要求: