mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-16 10:32:00 +00:00
合入 W2-d 访问密钥与服务账号:服务账号(管理员建、不能登录)与个人访问密钥(管理员开关,缺省关);只存哈希、必设到期、轮换与撤销;按路由白名单放行、封顶在使用者边界(看到的都遮过);发起入口和刷新视图必须带幂等键;视图数据接口 agentlab.viewdata/1;审计、请求记录、钩子收件记录;接口说明;设置里的访问密钥页
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* 访问密钥与服务账号(/api/access-keys,docs/design/next-round/04-对外集成与触达.md A1–A7),挂在 api.accessKeys 上。形状见
|
||||
* typesApp.ts。密钥明文只在建、轮换的回包里(key)出现一次,之后哪个接口都拿不到。
|
||||
*/
|
||||
import type {
|
||||
AccessKeyIssued, AccessKeyReference, AccessKeyRequestRow, AccessKeyRow, AccessKeyScope, AccessKeySettings,
|
||||
ServiceAccountRow,
|
||||
} from '../typesApp'
|
||||
import { get, patch, post, put } from './http'
|
||||
|
||||
const at = (id: string) => `/access-keys/${encodeURIComponent(id)}`
|
||||
|
||||
export const accessKeys = {
|
||||
settings: () => get<AccessKeySettings>('/access-keys/settings'),
|
||||
/** 个人访问密钥的开关(只给管理员) */
|
||||
setPersonalKeys: (personal_keys: boolean) => put<AccessKeySettings>('/access-keys/settings', { personal_keys }),
|
||||
/** 管理员:全部密钥;别人:自己的 */
|
||||
list: async (): Promise<AccessKeyRow[]> => (await get<{ items: AccessKeyRow[] }>('/access-keys')).items,
|
||||
/** 不给 service_account_id 是建自己的个人访问密钥 */
|
||||
create: (body: { name: string; scopes: AccessKeyScope[]; app_ids?: string[] | null; expires_in_days: number;
|
||||
service_account_id?: string }) => post<AccessKeyIssued>('/access-keys', body),
|
||||
revoke: (id: string) => post<AccessKeyRow>(`${at(id)}/revoke`),
|
||||
rotate: (id: string) => post<AccessKeyIssued>(`${at(id)}/rotate`),
|
||||
requests: (id: string) => get<{ items: AccessKeyRequestRow[]; retain_days: number }>(`${at(id)}/requests`),
|
||||
reference: () => get<AccessKeyReference>('/access-keys/reference'),
|
||||
serviceAccounts: async (): Promise<ServiceAccountRow[]> =>
|
||||
(await get<{ items: ServiceAccountRow[] }>('/access-keys/service-accounts')).items,
|
||||
createServiceAccount: (body: { username: string; display_name?: string }) =>
|
||||
post<ServiceAccountRow>('/access-keys/service-accounts', body),
|
||||
updateServiceAccount: (id: string, body: { display_name?: string; disabled?: boolean }) =>
|
||||
patch<ServiceAccountRow>(`/access-keys/service-accounts/${encodeURIComponent(id)}`, body),
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
* 入口提交校验失败回 422,ApiError 的 body 里带 {errors: FormError[]}。
|
||||
*/
|
||||
import type {
|
||||
AppBindings, AppDetail, AppGrant, AppHookRow, AppList, AppSpec, AppSummary, AppVersionRow, BackfillPlan, BackfillResult,
|
||||
AppBindings, AppDetail, AppGrant, AppHookRow, AppList, HookReceipts, AppSpec, AppSummary, AppVersionRow, BackfillPlan, BackfillResult,
|
||||
ComponentCatalog, Disposition, InstanceRow, LintIssue, PublishResult, ViewModel,
|
||||
} from '../typesApp'
|
||||
import type { ConversationDetail, EvidenceSegmentDetail } from '../types'
|
||||
@@ -72,6 +72,8 @@ export const apps = {
|
||||
setHookEnabled: (id: string, name: string, enabled: boolean) => patch<AppHookRow>(hookAt(id, name), { enabled }),
|
||||
/** 删掉这个名字的密钥行:外部系统再用旧密钥签的请求一律拒收 */
|
||||
deleteHook: (id: string, name: string) => del(hookAt(id, name)),
|
||||
/** 钩子最近收到的请求(manage):状态、原因、发起的实例或解决的待办,加近 1 小时验签失败几次(04 细案 A6) */
|
||||
hookReceipts: (id: string, name: string) => get<HookReceipts>(`${hookAt(id, name)}/receipts`),
|
||||
/**
|
||||
* 应用编辑器里助手的对话(D-e,manage):取这个应用的那段对话,没有就建(kind=app、归属这个应用)。带着历史轮次;
|
||||
* 老服务端只回对话本身时由调用方再按 id 取一次
|
||||
|
||||
@@ -29,6 +29,7 @@ import { reportExport } from './reportExport'
|
||||
import { apps, ledger } from './apps'
|
||||
import { actions, tasks } from './tasks'
|
||||
import { auth, identity } from './auth'
|
||||
import { accessKeys } from './accessKeys'
|
||||
import { capabilities, endpoints, notify } from './capabilities'
|
||||
// 普通用户建应用(typesBlueprint.ts 是接口约定)
|
||||
import { blueprints, files, personal, templates } from './blueprints'
|
||||
@@ -958,6 +959,8 @@ export const api = {
|
||||
actions,
|
||||
auth,
|
||||
identity,
|
||||
// 访问密钥与服务账号(下一轮第 2 波)
|
||||
accessKeys,
|
||||
capabilities,
|
||||
endpoints,
|
||||
notify,
|
||||
|
||||
Reference in New Issue
Block a user