feat(api-keys): add platform-scoped API keys for control-plane automation

Introduce platform API keys with capability-based access to tenant management,
system settings, runtime queues, and audit logs, plus admin UI for key lifecycle
and system audit log viewing.
This commit is contained in:
wizardchen
2026-07-21 15:05:57 +08:00
committed by lyingbug
parent c695125dce
commit 23db592c4a
42 changed files with 2967 additions and 1083 deletions
+126 -2
View File
@@ -10091,7 +10091,7 @@
},
{
"type": "string",
"description": "来源过滤:web / feishu / wechat / slack / ...",
"description": "来源过滤:web / embed / api / feishu / wechat / slack / ...(api、embed、IM 渠道需 Admin+)",
"name": "source",
"in": "query"
},
@@ -11538,6 +11538,105 @@
}
}
},
"/system/admin/api-keys": {
"get": {
"security": [
{
"Bearer": []
}
],
"description": "Lists non-workspace API keys. Full tokens are always masked. Human SystemAdmin only.",
"produces": [
"application/json"
],
"tags": [
"System Admin"
],
"summary": "List platform API keys",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
},
"post": {
"security": [
{
"Bearer": []
}
],
"description": "Creates a capability-scoped key that may target any workspace through X-Tenant-ID. The plaintext token is returned once. Human SystemAdmin only.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"System Admin"
],
"summary": "Create a platform API key",
"parameters": [
{
"description": "Platform API key",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/internal_handler.platformAPIKeyCreateRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
}
},
"/system/admin/api-keys/{key_id}": {
"delete": {
"security": [
{
"Bearer": []
}
],
"description": "Immediately revokes a platform API key. Human SystemAdmin only.",
"produces": [
"application/json"
],
"tags": [
"System Admin"
],
"summary": "Revoke a platform API key",
"parameters": [
{
"type": "integer",
"description": "API key ID",
"name": "key_id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object",
"additionalProperties": true
}
}
}
}
},
"/system/admin/audit-log": {
"get": {
"security": [
@@ -14738,6 +14837,8 @@
"system.admin_promoted",
"system.admin_revoked",
"system.user_password_reset",
"system.api_key_created",
"system.api_key_revoked",
"system.queue_task_retried",
"system.queue_task_deleted",
"system.queue_task_run_now",
@@ -14764,6 +14865,8 @@
"AuditActionSystemAdminPromoted",
"AuditActionSystemAdminRevoked",
"AuditActionSystemUserPasswordReset",
"AuditActionSystemAPIKeyCreated",
"AuditActionSystemAPIKeyRevoked",
"AuditActionSystemQueueTaskRetried",
"AuditActionSystemQueueTaskDeleted",
"AuditActionSystemQueueTaskRunNow",
@@ -18290,6 +18393,10 @@
"description": "ID",
"type": "string"
},
"im_platform": {
"description": "IMPlatform is the originating IM platform (e.g. \"feishu\", \"wecom\") when\nthis session is bound to an IM channel. It is not stored on the sessions\ntable (it lives in im_channel_sessions) and is populated on read so the\nWeb console can classify a session's origin folder without a list query.",
"type": "string"
},
"is_pinned": {
"description": "IsPinned indicates whether the session is pinned in the list.",
"type": "boolean"
@@ -21466,6 +21573,23 @@
}
}
},
"internal_handler.platformAPIKeyCreateRequest": {
"type": "object",
"properties": {
"capabilities": {
"type": "array",
"items": {
"type": "string"
}
},
"expires_at_unix": {
"type": "integer"
},
"name": {
"type": "string"
}
}
},
"internal_handler.registerByInviteRequest": {
"type": "object",
"required": [
@@ -21828,7 +21952,7 @@
},
"securityDefinitions": {
"ApiKeyAuth": {
"description": "空间身份认证:输入 sk- 开头的 API Key",
"description": "API Key 认证:空间 Key 固定访问所属空间;平台 Key 调用空间接口时需同时传 X-Tenant-ID",
"type": "apiKey",
"name": "X-API-Key",
"in": "header"