feat(auth,gateway,user): X-API-Key 真接线 + key 一律超管 + owner 档案真落盘(裁决 15.4.2/15.4.3/10.4.5/08.4.2)
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

- 15.4.2:管理 API 与 Bearer 共用同一 Authorize 路径,X-API-Key 命中签发表即过门;未知/已吊销/空值 401 且不回落 Bearer(fail-closed)
- 15.4.3:key 表去掉角色维度,任一有效 key 鉴权后即 owner;签发接口取消 role 分级(不再读请求体)
- 10.4.5:新增 GET/PUT /api/v1/admin/owner-profile(owner-only,PUT 带审计 owner.profile.update),0600 原子落盘 + 活档案热替换;前端主人档案改接真实 API,读不到即禁用保存,删掉硬编码默认档案
- 08.4.2:persona 的 identity.systemPrompt 必填,缺失/空白 400 显式报错,不再派生回落
This commit is contained in:
AskaEth committed 2026-10-04 12:07:51 +08:00
1 parent 8c6466cb00
commit adef36538f
13 files changed
+1223 -199

No files matched your search

+20 -5
View File
@@ -24,6 +24,7 @@ import type {
PersonaUpsertRequest,
PluginInstallRequest,
PluginInstallResult,
OwnerProfile,
RagIndexRequest,
SessionMeta,
SessionRecord,
@@ -149,11 +150,25 @@ export function adminCreateUser(req: { username: string; role: string }): Promis
body: JSON.stringify(req),
});
}
/** POST /api/v1/admin/users/apikey — mints a key; the plaintext comes back once. */
export function adminIssueApiKey(role: string): Promise<ApiKeyIssueResult> {
return request<ApiKeyIssueResult>("/admin/users/apikey", {
method: "POST",
body: JSON.stringify({ role }),
/** POST /api/v1/admin/users/apikey — mints a key; the plaintext comes back once.
* 裁决 15.4.3:key 一律超级管理员,不按 role 分档 ⇒ 请求体不带 role,
* 响应里的 `role` 如实回报实际授予的角色(恒为 owner)。 */
export function adminIssueApiKey(): Promise<ApiKeyIssueResult> {
return request<ApiKeyIssueResult>("/admin/users/apikey", { method: "POST" });
}
/** GET /api/v1/admin/owner-profile — 主人档案(owner-only):owner.yaml 的
* 显示名/默认人格/身份说明书/关系备注 + 各渠道账号白名单(策略引擎据此比对
* actor 元数据来认出主人)。全新安装返回空白档案(不是 404)。 */
export function adminGetOwnerProfile(): Promise<OwnerProfile> {
return request<OwnerProfile>("/admin/owner-profile");
}
/** PUT /api/v1/admin/owner-profile — 真实落盘(0600 原子写)+ 热替换活档案,
* 因此新白名单立即参与 owner 判定。校验失败回 400、落盘失败回 500 ——
* 调用方必须把失败呈现给用户,**不得假装保存成功**。 */
export function adminSaveOwnerProfile(profile: OwnerProfile): Promise<OwnerProfile> {
return request<OwnerProfile>("/admin/owner-profile", {
method: "PUT",
body: JSON.stringify(profile),
});
}
/** DELETE /api/v1/admin/users/apikey/{id} — revokes a key by masked id. */