feat: Add API key authentication system for external service access (#1757)

* Initial plan

* feat: Add API key authentication system backend

Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com>

* feat: Add API key management UI in frontend sidebar

Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com>

* fix: Correct import paths in API controller groups

Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com>

* fix: Address code review feedback - add i18n and validation

Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com>

* refactor: Enable API key auth on existing endpoints instead of creating separate service API

- Added USER_TOKEN_OR_API_KEY auth type that accepts both authentication methods
- Removed separate /api/service/v1/models endpoints
- Updated existing endpoints (models, bots, pipelines) to accept API keys
- External services can now use API keys to access all existing LangBot APIs
- Updated documentation to reflect unified API approach

Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com>

* docs: Add OpenAPI specification for API key authenticated endpoints

Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com>

* chore: rename openapi spec

* perf: ui and i18n

* fix: ui bug

* chore: tidy docs

* chore: fix linter errors

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com>
Co-authored-by: Junyan Qin <rockchinq@gmail.com>
This commit is contained in:
Copilot
2025-11-07 14:08:11 +08:00
committed by GitHub
parent af82227dff
commit a076ce5756
18 changed files with 2899 additions and 13 deletions
+17
View File
@@ -58,6 +58,23 @@ const enUS = {
changePasswordSuccess: 'Password changed successfully',
changePasswordFailed:
'Failed to change password, please check your current password',
apiKeys: 'API Keys',
manageApiKeys: 'Manage API Keys',
createApiKey: 'Create API Key',
apiKeyName: 'API Key Name',
apiKeyDescription: 'API Key Description',
apiKeyValue: 'API Key Value',
apiKeyCreated: 'API key created successfully',
apiKeyDeleted: 'API key deleted successfully',
apiKeyDeleteConfirm: 'Are you sure you want to delete this API key?',
apiKeyNameRequired: 'API key name is required',
copyApiKey: 'Copy API Key',
apiKeyCopied: 'API key copied to clipboard',
noApiKeys: 'No API keys configured',
apiKeyHint:
'API keys allow external systems to access LangBot Service APIs',
actions: 'Actions',
apiKeyCreatedMessage: 'Please copy this API key.',
},
notFound: {
title: 'Page not found',
+17
View File
@@ -59,6 +59,23 @@ const jaJP = {
changePasswordSuccess: 'パスワードの変更に成功しました',
changePasswordFailed:
'パスワードの変更に失敗しました。現在のパスワードを確認してください',
apiKeys: 'API キー',
manageApiKeys: 'API キーの管理',
createApiKey: 'API キーを作成',
apiKeyName: 'API キー名',
apiKeyDescription: 'API キーの説明',
apiKeyValue: 'API キー値',
apiKeyCreated: 'API キーの作成に成功しました',
apiKeyDeleted: 'API キーの削除に成功しました',
apiKeyDeleteConfirm: 'この API キーを削除してもよろしいですか?',
apiKeyNameRequired: 'API キー名は必須です',
copyApiKey: 'API キーをコピー',
apiKeyCopied: 'API キーをクリップボードにコピーしました',
noApiKeys: 'API キーが設定されていません',
apiKeyHint:
'API キーを使用すると、外部システムが LangBot Service API にアクセスできます',
actions: 'アクション',
apiKeyCreatedMessage: 'この API キーをコピーしてください。',
},
notFound: {
title: 'ページが見つかりません',
+16
View File
@@ -57,6 +57,22 @@ const zhHans = {
passwordsDoNotMatch: '两次输入的密码不一致',
changePasswordSuccess: '密码修改成功',
changePasswordFailed: '密码修改失败,请检查当前密码是否正确',
apiKeys: 'API 密钥',
manageApiKeys: '管理 API 密钥',
createApiKey: '创建 API 密钥',
apiKeyName: 'API 密钥名称',
apiKeyDescription: 'API 密钥描述',
apiKeyValue: 'API 密钥值',
apiKeyCreated: 'API 密钥创建成功',
apiKeyDeleted: 'API 密钥删除成功',
apiKeyDeleteConfirm: '确定要删除此 API 密钥吗?',
apiKeyNameRequired: 'API 密钥名称不能为空',
copyApiKey: '复制 API 密钥',
apiKeyCopied: 'API 密钥已复制到剪贴板',
noApiKeys: '暂无 API 密钥',
apiKeyHint: 'API 密钥允许外部系统访问 LangBot 的 Service API',
actions: '操作',
apiKeyCreatedMessage: '请复制此 API 密钥。',
},
notFound: {
title: '页面不存在',
+16
View File
@@ -57,6 +57,22 @@ const zhHant = {
passwordsDoNotMatch: '兩次輸入的密碼不一致',
changePasswordSuccess: '密碼修改成功',
changePasswordFailed: '密碼修改失敗,請檢查當前密碼是否正確',
apiKeys: 'API 金鑰',
manageApiKeys: '管理 API 金鑰',
createApiKey: '建立 API 金鑰',
apiKeyName: 'API 金鑰名稱',
apiKeyDescription: 'API 金鑰描述',
apiKeyValue: 'API 金鑰值',
apiKeyCreated: 'API 金鑰建立成功',
apiKeyDeleted: 'API 金鑰刪除成功',
apiKeyDeleteConfirm: '確定要刪除此 API 金鑰嗎?',
apiKeyNameRequired: 'API 金鑰名稱不能為空',
copyApiKey: '複製 API 金鑰',
apiKeyCopied: 'API 金鑰已複製到剪貼簿',
noApiKeys: '暫無 API 金鑰',
apiKeyHint: 'API 金鑰允許外部系統訪問 LangBot 的 Service API',
actions: '操作',
apiKeyCreatedMessage: '請複製此 API 金鑰。',
},
notFound: {
title: '頁面不存在',