From aaec920a9cf9c633f2affa276ab735d01f6886b8 Mon Sep 17 00:00:00 2001 From: MercuialC <946196959@qq.com> Date: Fri, 18 Sep 2026 19:39:34 +0800 Subject: [PATCH] =?UTF-8?q?feat(audit):=20=E7=9F=A5=E8=AF=86=E5=BA=93?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E8=AE=B0=E5=BD=95=E5=AF=B9=20API=20Key=20?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E9=A2=9D=E5=A4=96=E6=98=BE=E7=A4=BA=20Key=20?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=20(#3405)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(audit): show API key name on knowledge-base activity API-key operations currently look like the first tenant user or "system". Snapshot the key id/name into activity details so the feed can tell which key initiated the change, without restoring key authorization onto async workers. Fixes #3402 * fix(frontend): show activity API key on a second line The 132px actor column truncates "user · API Key · name" into one ellipsis. Keep the person on the first line and the key name below. --------- Co-authored-by: MercuialC Co-authored-by: root --- frontend/src/i18n/locales/en-US.ts | 4 ++ frontend/src/i18n/locales/ja-JP.ts | 4 ++ frontend/src/i18n/locales/ko-KR.ts | 4 ++ frontend/src/i18n/locales/ru-RU.ts | 4 ++ frontend/src/i18n/locales/zh-CN.ts | 4 ++ .../KnowledgeBaseActivitySettings.vue | 71 +++++++++++++++++-- internal/application/service/kb_activity.go | 18 +++++ .../application/service/kb_activity_test.go | 65 +++++++++++++++++ internal/middleware/auth.go | 2 + internal/types/const.go | 3 + internal/types/context_clone.go | 3 + internal/types/context_helpers.go | 60 +++++++++++++--- internal/types/task_initiator_test.go | 52 ++++++++++++++ internal/types/tenant_api_key.go | 2 + website-docs/03-features/02-knowledge-base.md | 1 + website-docs/03-features/16-observability.md | 2 +- website-docs/04-api/02-api-tenant.md | 2 +- 17 files changed, 283 insertions(+), 18 deletions(-) diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts index c22b582d..3513faca 100755 --- a/frontend/src/i18n/locales/en-US.ts +++ b/frontend/src/i18n/locales/en-US.ts @@ -2898,6 +2898,8 @@ export default { targetType: 'Target type', targetId: 'Target ID', actorId: 'Initiator ID', + apiKeyName: 'API key name', + apiKeyId: 'API key ID', details: 'Details' }, drawer: { @@ -2907,6 +2909,8 @@ export default { targetChange: 'Change details' }, systemActor: 'System', + actorWithAPIKey: '{actor} · API Key · {name}', + actorAPIKey: 'API Key · {name}', knowledgeBase: 'Knowledge base', countItems: '{count} items', titleWithCount: '{title} and {count} more', diff --git a/frontend/src/i18n/locales/ja-JP.ts b/frontend/src/i18n/locales/ja-JP.ts index dfb3eace..cde600de 100644 --- a/frontend/src/i18n/locales/ja-JP.ts +++ b/frontend/src/i18n/locales/ja-JP.ts @@ -2898,6 +2898,8 @@ export default { targetType: '対象の種類', targetId: '対象ID', actorId: '実行者ID', + apiKeyName: 'APIキー名', + apiKeyId: 'APIキーID', details: '詳細' }, drawer: { @@ -2907,6 +2909,8 @@ export default { targetChange: '変更内容' }, systemActor: 'システム', + actorWithAPIKey: '{actor} · API Key · {name}', + actorAPIKey: 'API Key · {name}', knowledgeBase: 'ナレッジベース', countItems: '{count}件', titleWithCount: '{title}ほか{count}件', diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts index ca95ad2b..29f6e2b4 100755 --- a/frontend/src/i18n/locales/ko-KR.ts +++ b/frontend/src/i18n/locales/ko-KR.ts @@ -4532,6 +4532,8 @@ export default { end: '이전 기록이 없습니다', loadFailed: '활동 기록을 불러오지 못했습니다', systemActor: '시스템', + actorWithAPIKey: '{actor} · API Key · {name}', + actorAPIKey: 'API Key · {name}', knowledgeBase: '지식 베이스', countItems: '{count}개 항목', titleWithCount: '{title} 외 {count}개', @@ -4635,6 +4637,8 @@ export default { targetType: '대상 유형', targetId: '대상 ID', actorId: '시작자 ID', + apiKeyName: 'API 키 이름', + apiKeyId: 'API 키 ID', details: '상세' }, columns: { diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts index c5f0d89d..a373462b 100755 --- a/frontend/src/i18n/locales/ru-RU.ts +++ b/frontend/src/i18n/locales/ru-RU.ts @@ -4532,6 +4532,8 @@ export default { end: 'Более ранних записей нет', loadFailed: 'Не удалось загрузить историю', systemActor: 'Система', + actorWithAPIKey: '{actor} · API Key · {name}', + actorAPIKey: 'API Key · {name}', knowledgeBase: 'База знаний', countItems: '{count} элем.', titleWithCount: '{title} и ещё {count}', @@ -4635,6 +4637,8 @@ export default { targetType: 'Тип объекта', targetId: 'ID объекта', actorId: 'ID инициатора', + apiKeyName: 'Имя API-ключа', + apiKeyId: 'ID API-ключа', details: 'Подробности' }, columns: { diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts index 80a69938..e945d99d 100755 --- a/frontend/src/i18n/locales/zh-CN.ts +++ b/frontend/src/i18n/locales/zh-CN.ts @@ -4534,6 +4534,8 @@ export default { end: '没有更早的记录了', loadFailed: '活动记录加载失败', systemActor: '系统触发', + actorWithAPIKey: '{actor} · API Key · {name}', + actorAPIKey: 'API Key · {name}', knowledgeBase: '知识库', countItems: '共 {count} 项', titleWithCount: '{title} 等 {count} 项', @@ -4637,6 +4639,8 @@ export default { targetType: '对象类型', targetId: '对象 ID', actorId: '发起人 ID', + apiKeyName: 'API Key 名称', + apiKeyId: 'API Key ID', details: '详情' }, columns: { diff --git a/frontend/src/views/knowledge/settings/KnowledgeBaseActivitySettings.vue b/frontend/src/views/knowledge/settings/KnowledgeBaseActivitySettings.vue index 5f8b9e90..94a1d198 100644 --- a/frontend/src/views/knowledge/settings/KnowledgeBaseActivitySettings.vue +++ b/frontend/src/views/knowledge/settings/KnowledgeBaseActivitySettings.vue @@ -161,8 +161,11 @@