Files
lijiaoqiao/platform-token-runtime/README.md
Your Name c5de0220a0 docs(plan): align service authority boundaries
Update the supply-api and platform-token-runtime READMEs to reflect the single token authority model, record the changes in the execution log, and mark P1-A-07 and P1-A-08 complete in the master plan.
2026-04-21 09:03:05 +08:00

67 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Platform Token Runtime
> token 生命周期、introspection 与审计查询服务。
## 当前真实状态
- 服务入口是 `cmd/platform-token-runtime/main.go`,装配逻辑收口在 `internal/app/bootstrap.go`
- 当前可用接口包括 `issue``refresh``revoke``introspect``audit-events`
- `platform-token-runtime` 是唯一 token authority对外 introspection 仅暴露 canonical principal 最小字段边界,不在其他服务中复制 authority 语义。
- `TOKEN_RUNTIME_ENV=dev` 且未显式注入 store 时bootstrap 会自动使用内存 runtime store 与内存 audit store。
- `TOKEN_RUNTIME_ENV=staging``TOKEN_RUNTIME_ENV=prod` 时,支持通过 `TOKEN_RUNTIME_DATABASE_URL` 自动装配 PostgreSQL runtime store 与 audit store未提供 DSN 时仍会快速失败,而不是回退到内存实现。
- `audit-events` 当前始终保持可查询接口语义;默认内存 audit store 会返回真实事件,未提供查询能力的自定义 emitter 会返回空结果而不是 `501` 占位响应。
## 设计边界
1. 仅支持 `Authorization: Bearer <token>` 入站。
2. 外部 query key`key``api_key``token`)一律拒绝。
3. 不在任何响应或审计字段中输出 access token 明文。
4. canonical principal 最小字段边界为 `token_id``subject_id``tenant_id``role``scope``issued_at``expires_at``status`;若后续扩展字段,必须同步更新 DDL、OpenAPI、存储模型与审计字段。
## 本地运行
```bash
cd "/home/long/project/立交桥/platform-token-runtime"
go run ./cmd/platform-token-runtime
```
默认监听 `:18081`。可通过以下环境变量覆盖:
```bash
export TOKEN_RUNTIME_ADDR=":18081"
export TOKEN_RUNTIME_ENV="dev"
```
PostgreSQL 模式:
```bash
export TOKEN_RUNTIME_ENV="prod"
export TOKEN_RUNTIME_DATABASE_URL="postgres://postgres:secret@127.0.0.1:5432/token_runtime?sslmode=disable"
go run ./cmd/platform-token-runtime
```
## 验证命令
模块级验证:
```bash
cd "/home/long/project/立交桥/platform-token-runtime"
GOCACHE=/tmp/lijiaoqiao-go-cache-platform-token-runtime go test ./...
```
仓库级统一验证:
```bash
cd "/home/long/project/立交桥"
bash scripts/ci/repo_integrity_check.sh
```
## 关键文件
- `internal/app/bootstrap.go`环境判断、runtime store / audit store 装配。
- `internal/httpapi/token_api.go`HTTP 接口与审计查询输出。
- `internal/auth/service/runtime_store.go`:内存 runtime store。
- `internal/auth/service/audit_store.go`:内存 audit store 与审计查询。
- `internal/auth/service/postgres_runtime_store.go`PostgreSQL runtime store。
- `internal/auth/service/postgres_audit_store.go`PostgreSQL audit store。