diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts index ce160468..276f1f09 100755 --- a/frontend/src/i18n/locales/en-US.ts +++ b/frontend/src/i18n/locales/en-US.ts @@ -5760,23 +5760,23 @@ export default { apiKeys: 'API Keys', apiKeysDesc: 'Create separate keys per integration and restrict operation permissions plus knowledge-base access.', createApiKey: 'Create API Key', - createApiKeyDialogDesc: 'Set permissions and available knowledge bases.', + createApiKeyDialogDesc: 'Set the access role and available knowledge bases.', noApiKeys: 'No API keys', apiKeyName: 'Name', apiKeyValue: 'API Key', apiKeyNamePlaceholder: 'Example: MCP read-only access', apiKeyNameRequired: 'Enter an API key name', toggleApiKeyVisible: 'Show or hide API key', - apiKeyScopes: 'Permissions', - apiKeyScopeRequired: 'Select at least one permission', + apiKeyAccessRole: "Access role", + apiKeyAccessRoleHint: "Matches tenant member roles; requests are authorized by the selected role.", + accessRoleViewer: "Viewer", + accessRoleContributor: "Contributor", + accessRoleAdmin: "Admin", + accessRoleViewerDesc: "Query, search, and chat without modifying knowledge-base content.", + accessRoleContributorDesc: "Create, update, or delete knowledge-base content within the selected scope.", + accessRoleAdminDesc: "Manage tenant-level settings and integrations; cannot create, rotate, or delete API keys.", apiKeyKnowledgeScope: 'Knowledge bases', apiKeyKnowledgeScopePlaceholder: 'Leave empty to allow all knowledge bases', - scopeRead: 'Read', - scopeWrite: 'Write', - scopeAdmin: 'Admin', - scopeReadDesc: 'Query, search, and chat without changing knowledge-base content.', - scopeWriteDesc: 'Create, update, or delete knowledge-base content within the selected scope.', - scopeAdminDesc: 'Manage tenant-level settings; API keys cannot manage API keys.', allKnowledgeBases: 'All knowledge bases', createdAt: 'Created', actions: 'Actions', diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts index 70739792..d4f82887 100755 --- a/frontend/src/i18n/locales/ko-KR.ts +++ b/frontend/src/i18n/locales/ko-KR.ts @@ -5767,7 +5767,38 @@ export default { baseUrl: "API Base URL", baseUrlDesc: "REST API 경로와 함께 사용하세요.", apiKey: "테넌트 API Key", - apiKeyDesc: "API Key는 계속 테넌트 단위입니다. 사용자 ID는 아래 모드로 전달합니다.", + apiKeyDesc: "통합용 API Key를 권한 및 지식베이스 범위와 함께 생성하세요.", + apiKeys: "API Keys", + apiKeysDesc: "통합마다 별도 Key를 만들고 작업 권한 및 접근 가능한 지식베이스 범위를 제한합니다.", + createApiKey: "API Key 생성", + createApiKeyDialogDesc: "접근 역할과 사용 가능한 지식베이스 범위를 설정하세요.", + noApiKeys: "API Key 없음", + apiKeyName: "이름", + apiKeyValue: "API Key", + apiKeyNamePlaceholder: "예: MCP 읽기 전용", + apiKeyNameRequired: "API Key 이름을 입력하세요", + toggleApiKeyVisible: "API Key 표시 또는 숨기기", + apiKeyAccessRole: "접근 역할", + apiKeyAccessRoleHint: "워크스페이스 멤버 역할과 동일하며, 요청 시 선택한 역할로 인증됩니다.", + accessRoleViewer: "뷰어", + accessRoleContributor: "편집", + accessRoleAdmin: "관리자", + accessRoleViewerDesc: "조회, 검색 및 대화만 가능하며 지식베이스 내용은 수정하지 않습니다.", + accessRoleContributorDesc: "선택한 범위 내에서 지식베이스 콘텐츠를 생성, 수정 또는 삭제합니다.", + accessRoleAdminDesc: "테넌트 수준 설정 및 통합을 관리합니다. API Key 생성, 교체 또는 삭제는 불가합니다.", + apiKeyKnowledgeScope: "지식베이스 범위", + apiKeyKnowledgeScopePlaceholder: "비워 두면 모든 지식베이스 접근 허용", + allKnowledgeBases: "모든 지식베이스", + createdAt: "생성일", + actions: "작업", + deleteApiKey: "삭제", + deleteApiKeyConfirm: "삭제하면 이 API Key는 즉시 무효화되며, 사용 중인 통합이 중단됩니다.", + deleteApiKeySuccess: "API Key가 삭제되었습니다", + deleteApiKeyFailed: "API Key 삭제 실패", + createApiKeyFailed: "API Key 생성 실패", + loadApiKeysFailed: "API Key 목록 불러오기 실패", + apiKeyCreated: "API Key가 생성되었습니다", + apiKeyCreatedDesc: "API Key가 생성되었습니다. 목록에서 확인하거나 복사할 수 있습니다.", principalMode: "사용자 ID 모드", principalModeDesc: "API 요청이 최종 사용자를 어떻게 식별할지 설정합니다. 이 신원은 대화 Session과 MCP 도구 인증을 사용자별로 구분하며, API Key의 테넌트 관리자 권한은 바뀌지 않습니다.", diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts index 5b632c56..9f92faea 100755 --- a/frontend/src/i18n/locales/ru-RU.ts +++ b/frontend/src/i18n/locales/ru-RU.ts @@ -5588,7 +5588,38 @@ export default { baseUrl: 'Базовый URL API', baseUrlDesc: 'Используйте с путями REST API.', apiKey: 'API Key арендатора', - apiKeyDesc: 'API Key остаётся на уровне арендатора; идентификатор пользователя задаётся режимом ниже.', + apiKeyDesc: 'Создавайте API key с правами операций и областью баз знаний для интеграций.', + apiKeys: 'API Keys', + apiKeysDesc: 'Создавайте отдельные ключи для интеграций и ограничивайте права операций и доступ к базам знаний.', + createApiKey: 'Создать API Key', + createApiKeyDialogDesc: 'Укажите роль доступа и доступные базы знаний.', + noApiKeys: 'Нет API keys', + apiKeyName: 'Название', + apiKeyValue: 'API Key', + apiKeyNamePlaceholder: 'Например: MCP только чтение', + apiKeyNameRequired: 'Введите название API key', + toggleApiKeyVisible: 'Показать или скрыть API key', + apiKeyAccessRole: 'Роль доступа', + apiKeyAccessRoleHint: 'Соответствует роли участника workspace; запросы авторизуются по выбранной роли.', + accessRoleViewer: 'Наблюдатель', + accessRoleContributor: 'Редактор', + accessRoleAdmin: 'Администратор', + accessRoleViewerDesc: 'Запросы, поиск и диалог без изменения содержимого баз знаний.', + accessRoleContributorDesc: 'Создание, обновление или удаление записей в выбранном диапазоне баз знаний.', + accessRoleAdminDesc: 'Управление настройками арендатора и интеграциями; нельзя создавать, ротировать или удалять API keys.', + apiKeyKnowledgeScope: 'Базы знаний', + apiKeyKnowledgeScopePlaceholder: 'Оставьте пустым, чтобы разрешить доступ ко всем базам знаний', + allKnowledgeBases: 'Все базы знаний', + createdAt: 'Создано', + actions: 'Действия', + deleteApiKey: 'Удалить', + deleteApiKeyConfirm: 'После удаления этот API key будет немедленно отозван, и интеграции перестанут работать.', + deleteApiKeySuccess: 'API key удалён', + deleteApiKeyFailed: 'Не удалось удалить API key', + createApiKeyFailed: 'Не удалось создать API key', + loadApiKeysFailed: 'Не удалось загрузить список API keys', + apiKeyCreated: 'API key создан', + apiKeyCreatedDesc: 'API key создан; его можно скопировать из списка.', principalMode: 'Режим идентификации пользователя', principalModeDesc: 'Настройка того, как API-запросы идентифицируют конечного пользователя. Эта идентичность разделяет сессии диалога и авторизацию MCP-инструментов по пользователям, не сужая доступ API key уровня admin арендатора.', diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts index 8ef1f179..0e97726a 100755 --- a/frontend/src/i18n/locales/zh-CN.ts +++ b/frontend/src/i18n/locales/zh-CN.ts @@ -5773,23 +5773,23 @@ export default { apiKeys: "API Keys", apiKeysDesc: "为不同集成创建独立 Key,并限制操作权限与可访问知识库范围。", createApiKey: "创建 API Key", - createApiKeyDialogDesc: "设置访问权限和可用知识库范围。", + createApiKeyDialogDesc: "设置访问角色和可用知识库范围。", noApiKeys: "暂无 API Key", apiKeyName: "名称", apiKeyValue: "API Key", apiKeyNamePlaceholder: "例如:MCP 只读访问", apiKeyNameRequired: "请输入 API Key 名称", toggleApiKeyVisible: "显示或隐藏 API Key", - apiKeyScopes: "权限", - apiKeyScopeRequired: "请至少选择一个权限", + apiKeyAccessRole: "访问角色", + apiKeyAccessRoleHint: "与空间成员角色一致,请求时按所选角色鉴权。", + accessRoleViewer: "访客", + accessRoleContributor: "编辑", + accessRoleAdmin: "管理员", + accessRoleViewerDesc: "查询、检索和对话,不修改知识库内容。", + accessRoleContributorDesc: "创建、更新或删除知识库内容,受知识库范围限制。", + accessRoleAdminDesc: "管理租户级配置与集成设置;不能创建、轮换或删除 API 密钥。", apiKeyKnowledgeScope: "知识库范围", apiKeyKnowledgeScopePlaceholder: "留空表示允许访问全部知识库", - scopeRead: "读取", - scopeWrite: "写入", - scopeAdmin: "管理", - scopeReadDesc: "查询、检索和对话,不修改知识库内容。", - scopeWriteDesc: "创建、更新或删除知识库内容,受知识库范围限制。", - scopeAdminDesc: "管理租户级配置;不能用 API Key 管理 API Key。", allKnowledgeBases: "全部知识库", createdAt: "创建时间", actions: "操作", diff --git a/frontend/src/views/integrations/ApiIntegrationSettings.vue b/frontend/src/views/integrations/ApiIntegrationSettings.vue index 7942c0e3..e703601d 100644 --- a/frontend/src/views/integrations/ApiIntegrationSettings.vue +++ b/frontend/src/views/integrations/ApiIntegrationSettings.vue @@ -114,7 +114,7 @@ {{ $t('integrations.api.apiKeyName') }} {{ $t('integrations.api.apiKeyValue') }} - {{ $t('integrations.api.apiKeyScopes') }} + {{ $t('integrations.api.apiKeyAccessRole') }} {{ $t('integrations.api.apiKeyKnowledgeScope') }} {{ $t('integrations.api.createdAt') }} {{ $t('integrations.api.actions') }} @@ -129,11 +129,9 @@ {{ formatKeyMaskedValue(key) }} -
- - {{ scope }} - -
+ + {{ formatApiKeyAccessRoleLabel(key.scopes) }} + @@ -145,14 +143,6 @@
- - -
- {{ $t('integrations.api.createApiKey') }}
@@ -464,33 +454,23 @@
- +
- - {{ $t('integrations.api.scopeRead') }} - {{ $t('integrations.api.scopeWrite') }} - {{ $t('integrations.api.scopeAdmin') }} - -
-

- {{ $t('integrations.api.scopeRead') }} - {{ $t('integrations.api.scopeReadDesc') }} -

-

- {{ $t('integrations.api.scopeWrite') }} - {{ $t('integrations.api.scopeWriteDesc') }} -

-

- {{ $t('integrations.api.scopeAdmin') }} - {{ $t('integrations.api.scopeAdminDesc') }} -

+ + {{ $t('integrations.api.accessRoleViewer') }} + {{ $t('integrations.api.accessRoleContributor') }} + {{ $t('integrations.api.accessRoleAdmin') }} + +

{{ $t('integrations.api.apiKeyAccessRoleHint') }}

+
+

{{ formatApiKeyAccessRoleLabel(accessRoleToScopes(apiKeyForm.role)) }}

+

{{ apiKeyFormRoleDesc }}

@@ -500,7 +480,6 @@
([]) const apiKeysLoading = ref(false) const apiKeyDialogVisible = ref(false) const apiKeyCreating = ref(false) -const visibleAPIKeyIDs = ref>(new Set()) const knowledgeBasesLoading = ref(false) const knowledgeBases = ref>([]) const secretInput = ref('') @@ -590,12 +568,53 @@ const form = reactive({ require_direct_header: false, }) +type ApiKeyAccessRole = 'viewer' | 'contributor' | 'admin' + const apiKeyForm = reactive({ name: '', - scopes: ['read'] as TenantAPIKeyScope[], + role: 'viewer' as ApiKeyAccessRole, knowledge_base_ids: [] as string[], }) +function scopesToAccessRole(scopes: TenantAPIKeyScope[] | undefined): ApiKeyAccessRole { + const normalized = (scopes ?? []).map((scope) => scope.toLowerCase()) + if (normalized.includes('admin')) return 'admin' + if (normalized.includes('write')) return 'contributor' + return 'viewer' +} + +function accessRoleToScopes(role: ApiKeyAccessRole): TenantAPIKeyScope[] { + switch (role) { + case 'admin': + return ['admin'] + case 'contributor': + return ['write'] + default: + return ['read'] + } +} + +function formatApiKeyAccessRoleLabel(scopes: TenantAPIKeyScope[] | undefined): string { + const role = scopesToAccessRole(scopes) + const labels: Record = { + viewer: t('integrations.api.accessRoleViewer'), + contributor: t('integrations.api.accessRoleContributor'), + admin: t('integrations.api.accessRoleAdmin'), + } + return labels[role] +} + +const apiKeyFormRoleDesc = computed(() => { + switch (apiKeyForm.role) { + case 'admin': + return t('integrations.api.accessRoleAdminDesc') + case 'contributor': + return t('integrations.api.accessRoleContributorDesc') + default: + return t('integrations.api.accessRoleViewerDesc') + } +}) + type PlaygroundStatus = '' | 'running' | 'success' | 'failed' | 'stopped' type WeKnoraDesktopWindow = Window & { @@ -1118,7 +1137,7 @@ function openApiDoc() { function openCreateAPIKeyDialog() { apiKeyForm.name = '' - apiKeyForm.scopes = ['read'] + apiKeyForm.role = 'viewer' apiKeyForm.knowledge_base_ids = [] apiKeyDialogVisible.value = true void loadKnowledgeBaseOptions() @@ -1129,15 +1148,11 @@ async function createScopedAPIKey() { MessagePlugin.error(t('integrations.api.apiKeyNameRequired')) return } - if (apiKeyForm.scopes.length === 0) { - MessagePlugin.error(t('integrations.api.apiKeyScopeRequired')) - return - } apiKeyCreating.value = true try { const resp = await createTenantAPIKey(tenantId.value, { name: apiKeyForm.name.trim(), - scopes: apiKeyForm.scopes, + scopes: accessRoleToScopes(apiKeyForm.role), knowledge_base_ids: apiKeyForm.knowledge_base_ids, }) if (!resp.success || !resp.data?.api_key) { @@ -1145,7 +1160,6 @@ async function createScopedAPIKey() { } apiKeyDialogVisible.value = false apiKey.value = resp.data.api_key - visibleAPIKeyIDs.value = new Set([...visibleAPIKeyIDs.value, resp.data.id]) MessagePlugin.success(t('integrations.api.apiKeyCreated')) await loadAPIKeys() } catch (err: any) { @@ -1185,24 +1199,9 @@ function formatKeyKnowledgeScope(ids: string[] = []) { return names.join(', ') } -function isAPIKeyVisible(id: number) { - return visibleAPIKeyIDs.value.has(id) -} - -function toggleAPIKeyVisible(id: number) { - const next = new Set(visibleAPIKeyIDs.value) - if (next.has(id)) { - next.delete(id) - } else { - next.add(id) - } - visibleAPIKeyIDs.value = next -} - function formatKeyMaskedValue(key: TenantAPIKey) { const value = key.api_key || '' if (!value) return '-' - if (isAPIKeyVisible(key.id)) return value return maskAPIKey(value) } @@ -1694,12 +1693,6 @@ onBeforeUnmount(stopPlayground) white-space: nowrap; } -.scope-tags { - display: flex; - flex-wrap: wrap; - gap: 4px; - min-width: 0; -} .api-key-dialog { display: flex; @@ -1730,11 +1723,12 @@ onBeforeUnmount(stopPlayground) align-items: center; justify-content: center; flex-shrink: 0; - width: 18px; - height: 18px; - color: var(--td-text-color-secondary); - border-radius: 4px; - background: var(--td-bg-color-secondarycontainer); + color: var(--td-brand-color); + line-height: 0; + + :deep(.t-icon) { + display: inline-flex; + } } .api-key-create-title { @@ -1746,12 +1740,11 @@ onBeforeUnmount(stopPlayground) } .api-key-create-desc { - max-width: 300px; margin: 0; color: var(--td-text-color-placeholder); - font-size: 12px; + font-size: 13px; font-weight: 400; - line-height: 18px; + line-height: 20px; } .api-key-dialog-row { @@ -1777,7 +1770,7 @@ onBeforeUnmount(stopPlayground) align-items: center; gap: 8px; color: var(--td-text-color-primary); - font-size: 13px; + font-size: 14px; font-weight: 600; line-height: 1.45; @@ -1817,44 +1810,46 @@ onBeforeUnmount(stopPlayground) } } -.scope-checkbox-group { - display: grid; - grid-template-columns: repeat(3, minmax(0, 1fr)); - gap: 6px; +.api-key-role-radio { + display: flex; + width: 100%; + max-width: 100%; + + :deep(.t-radio-group) { + display: flex; + width: 100%; + } + + :deep(.t-radio-button) { + flex: 1 1 0; + min-width: 0; + justify-content: center; + } + + :deep(.t-radio-button__former) { + position: absolute; + width: 0; + height: 0; + margin: 0; + padding: 0; + } + + :deep(.t-radio-button__input) { + display: none; + } + + :deep(.t-radio-button__label) { + flex: 0 1 auto; + margin-left: 0; + text-align: center; + } } -.scope-checkbox-option { - min-width: 0; - height: 30px; - margin-right: 0 !important; - padding: 0 8px; - border: 1px solid var(--td-component-stroke); - border-radius: 4px; - background: transparent; - transition: border-color 0.15s ease, background 0.15s ease; - - &:hover { - border-color: var(--td-component-border); - background: var(--td-bg-color-secondarycontainer); - } - - :deep(.t-checkbox__input) { - flex: 0 0 auto; - } - - :deep(.t-checkbox__input .t-checkbox__inner) { - width: 14px; - height: 14px; - } - - :deep(.t-checkbox__label) { - color: var(--td-text-color-secondary); - font-size: 12px; - line-height: 30px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - } +.scope-role-hint { + margin: 8px 0 0; + color: var(--td-text-color-placeholder); + font-size: 12px; + line-height: 18px; } .scope-help { @@ -1865,23 +1860,23 @@ onBeforeUnmount(stopPlayground) border-radius: 4px; background: var(--td-bg-color-secondarycontainer); - p { - display: flex; - gap: 6px; + &--role { + margin-top: 8px; + } + + &__role { + margin: 0; + color: var(--td-text-color-secondary); + font-size: 13px; + font-weight: 600; + line-height: 20px; + } + + &__desc { margin: 0; color: var(--td-text-color-placeholder); - font-size: 11px; - line-height: 17px; - } - - strong { - flex: 0 0 auto; - color: var(--td-text-color-secondary); - font-weight: 600; - } - - span { - min-width: 0; + font-size: 12px; + line-height: 18px; } }