Refine scoped API key capabilities
This commit is contained in:
@@ -48,14 +48,46 @@ export interface APIPrincipalTestToken {
|
||||
external_user_id: string
|
||||
}
|
||||
|
||||
export type TenantAPIKeyRole = 'viewer' | 'contributor' | 'admin' | 'owner'
|
||||
// Bounded per-key grants for non-full-access API keys.
|
||||
// - 'retrieve': read/search knowledge-base data within scope
|
||||
// - 'chat': run the conversation flow (sessions + agent listing + self identity)
|
||||
// - 'read_agents': list/read agents without chat or authoring
|
||||
// - 'ingest': write content into allowed knowledge bases (docs/chunks/FAQ/tags/wiki)
|
||||
// - 'manage_kbs': manage existing knowledge-base metadata/configuration
|
||||
// - 'manage_agents': create/update/delete/copy agents
|
||||
// - 'message_history': search/read tenant chat-history metadata
|
||||
// - 'manage_models': manage tenant model definitions, checks, and credentials
|
||||
// - 'manage_mcp_services': manage MCP services, credentials, tool policies, and OAuth state
|
||||
// - 'manage_datasources': manage data-source connectors and sync jobs
|
||||
// - 'manage_channels': manage embed and IM channels
|
||||
// - 'manage_vector_stores': manage vector stores and parser/storage checks
|
||||
// - 'manage_web_search': manage web-search providers
|
||||
// - 'run_evaluations': run/read evaluation jobs
|
||||
// - 'manage_tenant_settings': read/update tenant integration settings (API principal mode, headers, tenant KV)
|
||||
export type TenantAPIKeyCapability =
|
||||
| 'retrieve'
|
||||
| 'chat'
|
||||
| 'read_agents'
|
||||
| 'ingest'
|
||||
| 'manage_kbs'
|
||||
| 'manage_agents'
|
||||
| 'message_history'
|
||||
| 'manage_models'
|
||||
| 'manage_mcp_services'
|
||||
| 'manage_datasources'
|
||||
| 'manage_channels'
|
||||
| 'manage_vector_stores'
|
||||
| 'manage_web_search'
|
||||
| 'run_evaluations'
|
||||
| 'manage_tenant_settings'
|
||||
|
||||
export interface TenantAPIKey {
|
||||
id: number
|
||||
name: string
|
||||
api_key: string
|
||||
role: TenantAPIKeyRole
|
||||
full_access: boolean
|
||||
knowledge_base_ids: string[]
|
||||
capabilities?: TenantAPIKeyCapability[]
|
||||
last_used_at?: string
|
||||
expires_at?: string
|
||||
created_at: string
|
||||
@@ -67,8 +99,9 @@ export interface CreatedTenantAPIKey extends TenantAPIKey {
|
||||
|
||||
export interface CreateTenantAPIKeyPayload {
|
||||
name: string
|
||||
role: TenantAPIKeyRole
|
||||
full_access?: boolean
|
||||
knowledge_base_ids?: string[]
|
||||
capabilities?: TenantAPIKeyCapability[]
|
||||
expires_at_unix?: number
|
||||
}
|
||||
|
||||
|
||||
@@ -5759,13 +5759,15 @@ 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 the access role and available knowledge bases.',
|
||||
createApiKeyDialogDesc: 'Choose capabilities and the knowledge-base scope this key may use.',
|
||||
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',
|
||||
apiKeyAccessMode: 'Access mode',
|
||||
apiKeyScopedAccess: 'Scoped access',
|
||||
apiKeyAccessRole: "Access role",
|
||||
apiKeyAccessType: "Access type",
|
||||
apiKeyAccessTypeHint: "\"Knowledge base\" operates within the KB scope at the permission level below; \"Tenant full\" additionally unlocks every tenant-level API such as models and data sources.",
|
||||
@@ -5780,10 +5782,48 @@ export default {
|
||||
accessRoleViewerDesc: "Query, search, and chat without modifying knowledge-base content.",
|
||||
accessRoleContributorDesc: "Create, update, or delete knowledge-base content within the selected scope.",
|
||||
accessRoleAdminDesc: "Manage knowledge bases, including destructive operations like clearing a KB, within the selected scope; no tenant-level configuration.",
|
||||
accessRoleOwnerDesc: "Full access, equivalent to a tenant owner: may call every tenant-level API (models, vector stores, data sources, channels, ...). Not limited by knowledge-base scope.",
|
||||
apiKeyKnowledgeScope: 'Knowledge bases',
|
||||
accessRoleOwnerDesc: "Full access, equivalent to a tenant owner: may call every tenant-level API (models, vector stores, data sources, channels, ...). Not limited by knowledge-base scope.",
|
||||
apiKeyCapabilities: 'Capabilities',
|
||||
apiKeyCapabilityGroupKnowledge: 'Knowledge-base data',
|
||||
apiKeyCapabilityGroupAutomation: 'Agents and integrations',
|
||||
apiKeyCapabilityGroupTenant: 'Tenant configuration',
|
||||
apiKeyCapabilitySelectGroup: 'Select all',
|
||||
apiKeyCapabilityClearGroup: 'Clear',
|
||||
capabilityTenantFull: 'Tenant full access',
|
||||
capabilityTenantFullHint: 'Allow every tenant-level API, including models, vector stores, data sources and channels. Knowledge-base scope does not apply.',
|
||||
capabilityRetrieve: 'Retrieve knowledge bases',
|
||||
capabilityRetrieveHint: 'Read, query, and search data inside the selected knowledge-base scope. Does not create sessions or modify content.',
|
||||
capabilityChat: 'Chat',
|
||||
capabilityChatHint: 'Let this key hold conversations and manage its own sessions. Does not modify knowledge-base content.',
|
||||
capabilityReadAgents: 'Read agents',
|
||||
capabilityReadAgentsHint: 'List agents, read agent details, presets, and suggested questions. Does not allow chat or agent edits.',
|
||||
capabilityIngest: 'Write KB content',
|
||||
capabilityIngestHint: 'Let this key write content into its allowed knowledge bases (upload documents, edit chunks/FAQ/tags/wiki). It cannot create knowledge bases or agents, cannot clear a knowledge base, and stays bounded to the selected knowledge bases.',
|
||||
capabilityManageKbs: 'Manage knowledge bases',
|
||||
capabilityManageKbsHint: 'Let this key update or delete existing knowledge bases and change their initialization/configuration within the selected scope. It does not create new knowledge bases.',
|
||||
capabilityManageAgents: 'Manage agents',
|
||||
capabilityManageAgentsHint: 'Let this key create, update, delete and copy agents. Agent config can carry sensitive model/MCP bindings, so this is off by default — enable only when needed.',
|
||||
capabilityMessageHistory: 'Message history',
|
||||
capabilityMessageHistoryHint: 'Let this key search tenant chat history and read chat-history stats. It does not grant tenant configuration access.',
|
||||
capabilityManageModels: 'Manage models',
|
||||
capabilityManageModelsHint: 'Manage model definitions, credentials, connectivity checks, and WeKnoraCloud credentials.',
|
||||
capabilityManageMcpServices: 'Manage MCP services',
|
||||
capabilityManageMcpServicesHint: 'Manage MCP services, credentials, tool approval policies, and OAuth state for this principal.',
|
||||
capabilityManageDatasources: 'Manage data sources',
|
||||
capabilityManageDatasourcesHint: 'Manage data-source connectors, credentials, resource selection, and sync jobs. Knowledge-base scope still applies when a source is bound to a KB.',
|
||||
capabilityManageChannels: 'Manage channels',
|
||||
capabilityManageChannelsHint: 'Manage agent embed channels, IM channels, and WeChat QR binding flows.',
|
||||
capabilityManageVectorStores: 'Manage retrieval infrastructure',
|
||||
capabilityManageVectorStoresHint: 'Manage vector-store configuration plus parser, document reader, and storage engine connectivity checks.',
|
||||
capabilityManageWebSearch: 'Manage web search',
|
||||
capabilityManageWebSearchHint: 'Manage web-search provider configurations, credentials, and connection tests.',
|
||||
capabilityRunEvaluations: 'Run evaluations',
|
||||
capabilityRunEvaluationsHint: 'Run evaluation jobs and read evaluation results.',
|
||||
capabilityManageTenantSettings: 'Manage tenant settings',
|
||||
capabilityManageTenantSettingsHint: 'Read and update tenant-level integration settings such as API end-user identity mode, request header configuration, and tenant KV settings. Does not include API key management, member management, tenant deletion, or ownership transfer.',
|
||||
apiKeyKnowledgeScope: 'Knowledge bases',
|
||||
apiKeyKnowledgeScopePlaceholder: 'Leave empty to allow all knowledge bases',
|
||||
apiKeyKnowledgeScopeOwnerHint: 'Owner is a full-access key; the knowledge-base scope does not apply to it.',
|
||||
apiKeyKnowledgeScopeOwnerHint: 'Full-access keys are not limited by knowledge-base scope.',
|
||||
allKnowledgeBases: 'All knowledge bases',
|
||||
createdAt: 'Created',
|
||||
actions: 'Actions',
|
||||
|
||||
@@ -5770,13 +5770,15 @@ export default {
|
||||
apiKeys: "API Keys",
|
||||
apiKeysDesc: "통합마다 별도 Key를 만들고 작업 권한 및 접근 가능한 지식베이스 범위를 제한합니다.",
|
||||
createApiKey: "API Key 생성",
|
||||
createApiKeyDialogDesc: "접근 역할과 사용 가능한 지식베이스 범위를 설정하세요.",
|
||||
createApiKeyDialogDesc: "이 API Key가 사용할 기능과 지식베이스 범위를 선택하세요.",
|
||||
noApiKeys: "API Key 없음",
|
||||
apiKeyName: "이름",
|
||||
apiKeyValue: "API Key",
|
||||
apiKeyNamePlaceholder: "예: MCP 읽기 전용",
|
||||
apiKeyNameRequired: "API Key 이름을 입력하세요",
|
||||
toggleApiKeyVisible: "API Key 표시 또는 숨기기",
|
||||
apiKeyAccessMode: "접근 방식",
|
||||
apiKeyScopedAccess: "범위 지정 접근",
|
||||
apiKeyAccessRole: "접근 역할",
|
||||
apiKeyAccessType: "접근 유형",
|
||||
apiKeyAccessTypeHint: "\"지식베이스\"는 아래 권한 수준에 따라 지식베이스 범위 내에서 작동합니다. \"테넌트 전체 접근\"은 모델, 데이터 소스 등 모든 테넌트 수준 API를 추가로 사용할 수 있습니다.",
|
||||
@@ -5791,10 +5793,48 @@ export default {
|
||||
accessRoleViewerDesc: "조회, 검색 및 대화만 가능하며 지식베이스 내용은 수정하지 않습니다.",
|
||||
accessRoleContributorDesc: "선택한 범위 내에서 지식베이스 콘텐츠를 생성, 수정 또는 삭제합니다.",
|
||||
accessRoleAdminDesc: "선택한 범위 내에서 지식베이스를 관리하며, 지식베이스 비우기 등 파괴적 작업을 포함합니다. 테넌트 수준 설정은 다루지 않습니다.",
|
||||
accessRoleOwnerDesc: "전체 접근, 테넌트 소유자와 동일: 모델, 벡터 스토어, 데이터 소스, 채널 등 모든 테넌트 수준 API를 호출할 수 있으며 지식베이스 범위의 제한을 받지 않습니다.",
|
||||
apiKeyKnowledgeScope: "지식베이스 범위",
|
||||
accessRoleOwnerDesc: "전체 접근, 테넌트 소유자와 동일: 모델, 벡터 스토어, 데이터 소스, 채널 등 모든 테넌트 수준 API를 호출할 수 있으며 지식베이스 범위의 제한을 받지 않습니다.",
|
||||
apiKeyCapabilities: "사용 가능 기능",
|
||||
apiKeyCapabilityGroupKnowledge: "지식베이스 데이터",
|
||||
apiKeyCapabilityGroupAutomation: "에이전트 및 통합",
|
||||
apiKeyCapabilityGroupTenant: "테넌트 설정",
|
||||
apiKeyCapabilitySelectGroup: "전체 선택",
|
||||
apiKeyCapabilityClearGroup: "비우기",
|
||||
capabilityTenantFull: "테넌트 전체 접근",
|
||||
capabilityTenantFullHint: "모델, 벡터 스토어, 데이터 소스, 채널 등 모든 테넌트 수준 API를 허용합니다. 지식베이스 범위는 적용되지 않습니다.",
|
||||
capabilityRetrieve: "지식베이스 검색",
|
||||
capabilityRetrieveHint: "선택한 지식베이스 범위 내 데이터를 읽고 조회하고 검색할 수 있습니다. 세션을 만들거나 콘텐츠를 수정하지 않습니다.",
|
||||
capabilityChat: "대화 기능",
|
||||
capabilityChatHint: "이 키로 대화를 시작하고 자체 세션을 관리할 수 있습니다. 지식베이스 콘텐츠는 수정하지 않습니다.",
|
||||
capabilityReadAgents: "에이전트 읽기",
|
||||
capabilityReadAgentsHint: "에이전트 목록, 상세 정보, 프리셋 및 추천 질문을 읽을 수 있습니다. 대화 시작이나 에이전트 수정은 허용하지 않습니다.",
|
||||
capabilityIngest: "지식베이스 콘텐츠 쓰기",
|
||||
capabilityIngestHint: "허용된 지식베이스에 콘텐츠를 작성할 수 있습니다(문서 업로드, 청크/FAQ/태그/wiki 편집). 지식베이스나 에이전트를 새로 만들 수 없고, 지식베이스를 비울 수 없으며, 선택한 지식베이스 범위로 제한됩니다.",
|
||||
capabilityManageKbs: "지식베이스 관리",
|
||||
capabilityManageKbsHint: "선택한 범위 안에서 기존 지식베이스를 수정 또는 삭제하고 초기화/설정을 변경할 수 있습니다. 새 지식베이스 생성은 허용하지 않습니다.",
|
||||
capabilityManageAgents: "에이전트 관리",
|
||||
capabilityManageAgentsHint: "에이전트를 생성, 수정, 삭제, 복사할 수 있습니다. 에이전트 설정에는 모델/MCP 등 민감한 바인딩이 포함될 수 있으므로 기본적으로 꺼져 있으며 필요할 때만 켜세요.",
|
||||
capabilityMessageHistory: "메시지 기록",
|
||||
capabilityMessageHistoryHint: "테넌트 채팅 기록 검색과 채팅 기록 통계 조회를 허용합니다. 테넌트 설정 권한은 부여하지 않습니다.",
|
||||
capabilityManageModels: "모델 관리",
|
||||
capabilityManageModelsHint: "모델 설정, 자격 증명, 연결 테스트 및 WeKnoraCloud 자격 증명을 관리합니다.",
|
||||
capabilityManageMcpServices: "MCP 서비스 관리",
|
||||
capabilityManageMcpServicesHint: "MCP 서비스, 자격 증명, 도구 승인 정책 및 이 주체의 OAuth 상태를 관리합니다.",
|
||||
capabilityManageDatasources: "데이터 소스 관리",
|
||||
capabilityManageDatasourcesHint: "데이터 소스 커넥터, 자격 증명, 리소스 선택 및 동기화 작업을 관리합니다. 지식베이스에 연결된 경우 범위 제한은 계속 적용됩니다.",
|
||||
capabilityManageChannels: "채널 관리",
|
||||
capabilityManageChannelsHint: "에이전트 임베드 채널, IM 채널 및 WeChat QR 바인딩 흐름을 관리합니다.",
|
||||
capabilityManageVectorStores: "검색 인프라 관리",
|
||||
capabilityManageVectorStoresHint: "벡터 스토어 설정과 파서, 문서 리더, 스토리지 엔진 연결 검사를 관리합니다.",
|
||||
capabilityManageWebSearch: "웹 검색 관리",
|
||||
capabilityManageWebSearchHint: "웹 검색 공급자 설정, 자격 증명 및 연결 테스트를 관리합니다.",
|
||||
capabilityRunEvaluations: "평가 실행",
|
||||
capabilityRunEvaluationsHint: "평가 작업을 실행하고 결과를 읽을 수 있습니다.",
|
||||
capabilityManageTenantSettings: "테넌트 설정 관리",
|
||||
capabilityManageTenantSettingsHint: "API 최종 사용자 식별 모드, 요청 헤더 설정, 테넌트 KV 설정 등 테넌트 수준 통합 설정을 읽고 업데이트합니다. API Key 관리, 멤버 관리, 테넌트 삭제 또는 소유권 이전은 포함하지 않습니다.",
|
||||
apiKeyKnowledgeScope: "지식베이스 범위",
|
||||
apiKeyKnowledgeScopePlaceholder: "비워 두면 모든 지식베이스 접근 허용",
|
||||
apiKeyKnowledgeScopeOwnerHint: "소유자는 전체 접근 키이므로 지식베이스 범위가 적용되지 않습니다.",
|
||||
apiKeyKnowledgeScopeOwnerHint: "전체 접근 키는 지식베이스 범위로 제한되지 않습니다.",
|
||||
allKnowledgeBases: "모든 지식베이스",
|
||||
createdAt: "생성일",
|
||||
actions: "작업",
|
||||
|
||||
@@ -5591,13 +5591,15 @@ export default {
|
||||
apiKeys: 'API Keys',
|
||||
apiKeysDesc: 'Создавайте отдельные ключи для интеграций и ограничивайте права операций и доступ к базам знаний.',
|
||||
createApiKey: 'Создать API Key',
|
||||
createApiKeyDialogDesc: 'Укажите роль доступа и доступные базы знаний.',
|
||||
createApiKeyDialogDesc: 'Выберите возможности ключа и доступный диапазон баз знаний.',
|
||||
noApiKeys: 'Нет API keys',
|
||||
apiKeyName: 'Название',
|
||||
apiKeyValue: 'API Key',
|
||||
apiKeyNamePlaceholder: 'Например: MCP только чтение',
|
||||
apiKeyNameRequired: 'Введите название API key',
|
||||
toggleApiKeyVisible: 'Показать или скрыть API key',
|
||||
apiKeyAccessMode: 'Режим доступа',
|
||||
apiKeyScopedAccess: 'Ограниченный доступ',
|
||||
apiKeyAccessRole: 'Роль доступа',
|
||||
apiKeyAccessType: 'Тип доступа',
|
||||
apiKeyAccessTypeHint: '«База знаний» работает в пределах области БЗ на выбранном ниже уровне прав; «Полный доступ арендатора» дополнительно открывает все API уровня арендатора, такие как модели и источники данных.',
|
||||
@@ -5612,10 +5614,48 @@ export default {
|
||||
accessRoleViewerDesc: 'Запросы, поиск и диалог без изменения содержимого баз знаний.',
|
||||
accessRoleContributorDesc: 'Создание, обновление или удаление записей в выбранном диапазоне баз знаний.',
|
||||
accessRoleAdminDesc: 'Управление базами знаний в выбранном диапазоне, включая деструктивные операции, такие как очистка базы знаний; настройки уровня арендатора недоступны.',
|
||||
accessRoleOwnerDesc: 'Полный доступ, эквивалент владельца арендатора: доступны все API уровня арендатора (модели, векторные хранилища, источники данных, каналы, ...). Не ограничивается диапазоном баз знаний.',
|
||||
apiKeyKnowledgeScope: 'Базы знаний',
|
||||
accessRoleOwnerDesc: 'Полный доступ, эквивалент владельца арендатора: доступны все API уровня арендатора (модели, векторные хранилища, источники данных, каналы, ...). Не ограничивается диапазоном баз знаний.',
|
||||
apiKeyCapabilities: 'Возможности',
|
||||
apiKeyCapabilityGroupKnowledge: 'Данные баз знаний',
|
||||
apiKeyCapabilityGroupAutomation: 'Агенты и интеграции',
|
||||
apiKeyCapabilityGroupTenant: 'Настройки арендатора',
|
||||
apiKeyCapabilitySelectGroup: 'Выбрать всё',
|
||||
apiKeyCapabilityClearGroup: 'Очистить',
|
||||
capabilityTenantFull: 'Полный доступ арендатора',
|
||||
capabilityTenantFullHint: 'Разрешает все API уровня арендатора, включая модели, векторные хранилища, источники данных и каналы. Диапазон баз знаний не применяется.',
|
||||
capabilityRetrieve: 'Поиск в базах знаний',
|
||||
capabilityRetrieveHint: 'Чтение, запросы и поиск данных в выбранном диапазоне баз знаний. Не создаёт сессии и не изменяет содержимое.',
|
||||
capabilityChat: 'Диалог',
|
||||
capabilityChatHint: 'Позволяет этому ключу вести диалог и управлять собственными сессиями. Не изменяет содержимое баз знаний.',
|
||||
capabilityReadAgents: 'Чтение агентов',
|
||||
capabilityReadAgentsHint: 'Список агентов, детали, пресеты и предлагаемые вопросы. Не разрешает диалог или изменение агентов.',
|
||||
capabilityIngest: 'Запись в базы знаний',
|
||||
capabilityIngestHint: 'Позволяет ключу записывать содержимое в разрешённые базы знаний (загрузка документов, редактирование фрагментов/FAQ/тегов/wiki). Нельзя создавать базы знаний или агентов, нельзя очищать базу знаний; действие ограничено выбранными базами знаний.',
|
||||
capabilityManageKbs: 'Управление базами знаний',
|
||||
capabilityManageKbsHint: 'Позволяет обновлять или удалять существующие базы знаний и менять их конфигурацию в выбранной области. Не разрешает создавать новые базы знаний.',
|
||||
capabilityManageAgents: 'Управление агентами',
|
||||
capabilityManageAgentsHint: 'Позволяет создавать, изменять, удалять и копировать агентов. Конфигурация агента может содержать чувствительные привязки моделей/MCP, поэтому по умолчанию отключено — включайте только при необходимости.',
|
||||
capabilityMessageHistory: 'История сообщений',
|
||||
capabilityMessageHistoryHint: 'Позволяет искать историю чатов арендатора и читать статистику истории. Не даёт доступ к настройкам арендатора.',
|
||||
capabilityManageModels: 'Управление моделями',
|
||||
capabilityManageModelsHint: 'Управление конфигурациями моделей, учётными данными, проверками подключения и данными WeKnoraCloud.',
|
||||
capabilityManageMcpServices: 'Управление MCP-сервисами',
|
||||
capabilityManageMcpServicesHint: 'Управление MCP-сервисами, учётными данными, политиками подтверждения инструментов и OAuth-состоянием этого субъекта.',
|
||||
capabilityManageDatasources: 'Управление источниками данных',
|
||||
capabilityManageDatasourcesHint: 'Управление коннекторами, учётными данными, выбором ресурсов и синхронизацией. Для привязанных баз знаний диапазон всё равно применяется.',
|
||||
capabilityManageChannels: 'Управление каналами',
|
||||
capabilityManageChannelsHint: 'Управление embed-каналами агентов, IM-каналами и привязкой WeChat через QR-код.',
|
||||
capabilityManageVectorStores: 'Управление инфраструктурой поиска',
|
||||
capabilityManageVectorStoresHint: 'Управление векторными хранилищами и проверками парсеров, чтения документов и storage engine.',
|
||||
capabilityManageWebSearch: 'Управление веб-поиском',
|
||||
capabilityManageWebSearchHint: 'Управление провайдерами веб-поиска, учётными данными и проверками подключения.',
|
||||
capabilityRunEvaluations: 'Запуск оценок',
|
||||
capabilityRunEvaluationsHint: 'Запуск задач оценки и чтение результатов.',
|
||||
capabilityManageTenantSettings: 'Управление настройками арендатора',
|
||||
capabilityManageTenantSettingsHint: 'Чтение и обновление интеграционных настроек арендатора: режим идентификации конечного пользователя API, настройки заголовков запросов и tenant KV. Не включает управление API Key, участниками, удаление арендатора или передачу владения.',
|
||||
apiKeyKnowledgeScope: 'Базы знаний',
|
||||
apiKeyKnowledgeScopePlaceholder: 'Оставьте пустым, чтобы разрешить доступ ко всем базам знаний',
|
||||
apiKeyKnowledgeScopeOwnerHint: 'Владелец — это ключ с полным доступом; диапазон баз знаний к нему не применяется.',
|
||||
apiKeyKnowledgeScopeOwnerHint: 'Ключи с полным доступом не ограничиваются диапазоном баз знаний.',
|
||||
allKnowledgeBases: 'Все базы знаний',
|
||||
createdAt: 'Создано',
|
||||
actions: 'Действия',
|
||||
|
||||
@@ -5772,13 +5772,15 @@ export default {
|
||||
apiKeys: "API Keys",
|
||||
apiKeysDesc: "为不同集成创建独立 Key,并限制操作权限与可访问知识库范围。",
|
||||
createApiKey: "创建 API Key",
|
||||
createApiKeyDialogDesc: "设置访问角色和可用知识库范围。",
|
||||
createApiKeyDialogDesc: "选择该 API Key 可用的能力和知识库范围。",
|
||||
noApiKeys: "暂无 API Key",
|
||||
apiKeyName: "名称",
|
||||
apiKeyValue: "API Key",
|
||||
apiKeyNamePlaceholder: "例如:MCP 只读访问",
|
||||
apiKeyNameRequired: "请输入 API Key 名称",
|
||||
toggleApiKeyVisible: "显示或隐藏 API Key",
|
||||
apiKeyAccessMode: "授权方式",
|
||||
apiKeyScopedAccess: "能力授权",
|
||||
apiKeyAccessRole: "访问角色",
|
||||
apiKeyAccessType: "访问类型",
|
||||
apiKeyAccessTypeHint: "「知识库」按下方权限级别在知识库范围内操作;「租户完全访问」额外开放模型、数据源等全部租户级接口。",
|
||||
@@ -5793,10 +5795,48 @@ export default {
|
||||
accessRoleViewerDesc: "查询、检索和对话,不修改知识库内容。",
|
||||
accessRoleContributorDesc: "创建、更新或删除知识库内容,受知识库范围限制。",
|
||||
accessRoleAdminDesc: "知识库管理,包含清空知识库等破坏性操作,受知识库范围限制;不涉及租户级配置。",
|
||||
accessRoleOwnerDesc: "完全访问,等同租户所有者:可调用模型、向量库、数据源、渠道等全部租户级接口,不受知识库范围限制。",
|
||||
apiKeyKnowledgeScope: "知识库范围",
|
||||
accessRoleOwnerDesc: "完全访问,等同租户所有者:可调用模型、向量库、数据源、渠道等全部租户级接口,不受知识库范围限制。",
|
||||
apiKeyCapabilities: "可用能力",
|
||||
apiKeyCapabilityGroupKnowledge: "知识库数据",
|
||||
apiKeyCapabilityGroupAutomation: "智能体与集成",
|
||||
apiKeyCapabilityGroupTenant: "租户配置",
|
||||
apiKeyCapabilitySelectGroup: "全选",
|
||||
apiKeyCapabilityClearGroup: "清空",
|
||||
capabilityTenantFull: "租户完全访问",
|
||||
capabilityTenantFullHint: "允许调用模型、向量库、数据源、渠道等全部租户级接口;知识库范围不再生效。",
|
||||
capabilityRetrieve: "检索知识库",
|
||||
capabilityRetrieveHint: "允许读取、查询和检索所选知识库范围内的数据;不创建会话,也不修改内容。",
|
||||
capabilityChat: "对话能力",
|
||||
capabilityChatHint: "允许该密钥发起对话并管理自己的会话;不修改知识库内容。",
|
||||
capabilityReadAgents: "读取智能体",
|
||||
capabilityReadAgentsHint: "允许列出智能体、查看智能体详情、读取智能体预设和建议问题;不允许发起对话或修改智能体。",
|
||||
capabilityIngest: "写入知识库内容",
|
||||
capabilityIngestHint: "允许向授权范围内的知识库写入内容(上传文档、编辑分块/FAQ/标签/wiki);不能新建知识库、不能新建智能体、不能清空知识库,且仅限所选知识库范围。",
|
||||
capabilityManageKbs: "管理知识库",
|
||||
capabilityManageKbsHint: "允许在所选知识库范围内修改或删除已有知识库,并调整初始化/配置信息;不允许新建知识库。",
|
||||
capabilityManageAgents: "管理智能体",
|
||||
capabilityManageAgentsHint: "允许创建、修改、删除、复制智能体。智能体配置可能含模型/MCP 等敏感绑定,默认关闭,按需开启。",
|
||||
capabilityMessageHistory: "消息历史",
|
||||
capabilityMessageHistoryHint: "允许检索租户聊天历史并读取聊天历史统计;不授予租户配置权限。",
|
||||
capabilityManageModels: "管理模型",
|
||||
capabilityManageModelsHint: "允许管理模型配置、模型凭据、模型连通性测试和 WeKnoraCloud 凭据。",
|
||||
capabilityManageMcpServices: "管理 MCP 服务",
|
||||
capabilityManageMcpServicesHint: "允许管理 MCP 服务、凭据、工具审批策略和该主体的 OAuth 授权状态。",
|
||||
capabilityManageDatasources: "管理数据源",
|
||||
capabilityManageDatasourcesHint: "允许管理数据源连接器、凭据、资源选择和同步任务;绑定知识库时仍受知识库范围限制。",
|
||||
capabilityManageChannels: "管理渠道",
|
||||
capabilityManageChannelsHint: "允许管理智能体的嵌入渠道、IM 渠道和微信扫码绑定流程。",
|
||||
capabilityManageVectorStores: "管理检索基础设施",
|
||||
capabilityManageVectorStoresHint: "允许管理向量库配置,以及解析器、文档读取器和存储引擎连通性检查。",
|
||||
capabilityManageWebSearch: "管理联网搜索",
|
||||
capabilityManageWebSearchHint: "允许管理联网搜索供应商配置、凭据和连接测试。",
|
||||
capabilityRunEvaluations: "运行评测",
|
||||
capabilityRunEvaluationsHint: "允许运行评测任务并读取评测结果。",
|
||||
capabilityManageTenantSettings: "管理租户设置",
|
||||
capabilityManageTenantSettingsHint: "允许读取和更新租户级集成设置,例如 API 终端用户身份模式、请求头配置、租户 KV 配置等;不包含 API Key 管理、成员管理、租户删除或所有权转移。",
|
||||
apiKeyKnowledgeScope: "知识库范围",
|
||||
apiKeyKnowledgeScopePlaceholder: "留空表示允许访问全部知识库",
|
||||
apiKeyKnowledgeScopeOwnerHint: "所有者为完全访问密钥,知识库范围对其不生效。",
|
||||
apiKeyKnowledgeScopeOwnerHint: "完全访问密钥不受知识库范围限制。",
|
||||
allKnowledgeBases: "全部知识库",
|
||||
createdAt: "创建时间",
|
||||
actions: "操作",
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
<tr>
|
||||
<th>{{ $t('integrations.api.apiKeyName') }}</th>
|
||||
<th>{{ $t('integrations.api.apiKeyValue') }}</th>
|
||||
<th>{{ $t('integrations.api.apiKeyAccessRole') }}</th>
|
||||
<th>{{ $t('integrations.api.apiKeyAccessMode') }}</th>
|
||||
<th>{{ $t('integrations.api.apiKeyKnowledgeScope') }}</th>
|
||||
<th>{{ $t('integrations.api.createdAt') }}</th>
|
||||
<th class="api-key-table__actions-heading">{{ $t('integrations.api.actions') }}</th>
|
||||
@@ -129,9 +129,23 @@
|
||||
<code class="api-key-fingerprint">{{ formatKeyMaskedValue(key) }}</code>
|
||||
</td>
|
||||
<td>
|
||||
<t-tag size="small" variant="light">
|
||||
{{ formatApiKeyAccessRoleLabel(key.role) }}
|
||||
</t-tag>
|
||||
<div class="api-key-access-cell" :title="formatApiKeyCapabilitiesTitle(key)">
|
||||
<span
|
||||
v-if="key.full_access"
|
||||
class="api-key-access-mode api-key-access-mode--full"
|
||||
>
|
||||
{{ formatApiKeyAccessModeLabel(key) }}
|
||||
</span>
|
||||
<div v-if="!key.full_access" class="api-key-capability-chips">
|
||||
<span
|
||||
v-for="label in keyCapabilityLabels(key)"
|
||||
:key="label"
|
||||
class="api-key-capability-chip"
|
||||
>
|
||||
{{ label }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<span class="api-key-knowledge-scope">
|
||||
@@ -427,26 +441,22 @@
|
||||
</section>
|
||||
</SettingDrawer>
|
||||
|
||||
<t-dialog
|
||||
v-model:visible="apiKeyDialogVisible"
|
||||
:footer="false"
|
||||
width="450px"
|
||||
dialog-class-name="api-key-create-dialog"
|
||||
<SettingDrawer
|
||||
:visible="apiKeyDialogVisible"
|
||||
class="api-key-create-drawer"
|
||||
:title="$t('integrations.api.createApiKey')"
|
||||
:description="$t('integrations.api.createApiKeyDialogDesc')"
|
||||
icon="lock-on"
|
||||
width="560px"
|
||||
:min-width="480"
|
||||
:max-width="920"
|
||||
storage-key="setting-drawer:width:api-key-create"
|
||||
:close-on-overlay-click="false"
|
||||
destroy-on-close
|
||||
:confirm-text="$t('integrations.api.createApiKey')"
|
||||
:confirm-loading="apiKeyCreating"
|
||||
@update:visible="(v: boolean) => apiKeyDialogVisible = v"
|
||||
@confirm="createScopedAPIKey"
|
||||
>
|
||||
<template #header>
|
||||
<div class="api-key-create-heading">
|
||||
<div class="api-key-create-heading-row">
|
||||
<span class="api-key-create-heading-mark">
|
||||
<t-icon name="lock-on" size="16px" aria-hidden="true" />
|
||||
</span>
|
||||
<span class="api-key-create-title">{{ $t('integrations.api.createApiKey') }}</span>
|
||||
</div>
|
||||
<p class="api-key-create-desc">{{ $t('integrations.api.createApiKeyDialogDesc') }}</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="api-key-dialog">
|
||||
<div class="api-key-dialog-row">
|
||||
<div class="api-key-dialog-row__label">
|
||||
@@ -462,32 +472,63 @@
|
||||
<div class="api-key-dialog-row__label">
|
||||
<label>{{ $t('integrations.api.apiKeyAccessType') }}</label>
|
||||
</div>
|
||||
<t-radio-group v-model="apiKeyAccessType" class="mode-radio api-key-role-radio">
|
||||
<t-radio-button value="kb">{{ $t('integrations.api.accessTypeKnowledgeBase') }}</t-radio-button>
|
||||
<t-radio-button value="tenant">{{ $t('integrations.api.accessTypeTenantFull') }}</t-radio-button>
|
||||
<t-radio-group v-model="apiKeyAccessMode" class="mode-radio api-key-access-type-radio">
|
||||
<t-radio-button value="scoped">{{ $t('integrations.api.apiKeyScopedAccess') }}</t-radio-button>
|
||||
<t-radio-button value="full">{{ $t('integrations.api.capabilityTenantFull') }}</t-radio-button>
|
||||
</t-radio-group>
|
||||
<p class="scope-role-hint">{{ $t('integrations.api.apiKeyAccessTypeHint') }}</p>
|
||||
<p class="scope-hint">
|
||||
{{
|
||||
apiKeyFullAccessEnabled
|
||||
? $t('integrations.api.capabilityTenantFullHint')
|
||||
: $t('integrations.api.apiKeyAccessTypeHint')
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div v-if="!apiKeyRoleIsOwner" class="api-key-dialog-row">
|
||||
<div v-if="!apiKeyFullAccessEnabled" class="api-key-dialog-row">
|
||||
<div class="api-key-dialog-row__label">
|
||||
<label>{{ $t('integrations.api.apiKeyPermissionLevel') }}</label>
|
||||
<label>{{ $t('integrations.api.apiKeyCapabilities') }}</label>
|
||||
</div>
|
||||
<t-radio-group v-model="apiKeyForm.role" class="mode-radio api-key-role-radio">
|
||||
<t-radio-button value="viewer">{{ $t('integrations.api.accessRoleViewer') }}</t-radio-button>
|
||||
<t-radio-button value="contributor">{{ $t('integrations.api.accessRoleContributor') }}</t-radio-button>
|
||||
<t-radio-button value="admin">{{ $t('integrations.api.accessRoleAdmin') }}</t-radio-button>
|
||||
</t-radio-group>
|
||||
</div>
|
||||
|
||||
<div class="api-key-dialog-row api-key-dialog-row--help">
|
||||
<div class="scope-help scope-help--role">
|
||||
<p class="scope-help__role">{{ formatApiKeyAccessRoleLabel(apiKeyForm.role) }}</p>
|
||||
<p class="scope-help__desc">{{ apiKeyFormRoleDesc }}</p>
|
||||
<div v-if="!apiKeyFullAccessEnabled" class="api-key-capability-list">
|
||||
<div
|
||||
v-for="group in apiKeyCapabilityGroups"
|
||||
:key="group.key"
|
||||
class="api-key-capability-group"
|
||||
>
|
||||
<div class="api-key-capability-group__header">
|
||||
<span>{{ $t(group.labelKey) }}</span>
|
||||
<t-button
|
||||
size="small"
|
||||
variant="text"
|
||||
@click="toggleCapabilityGroup(group, !capabilityGroupAllSelected(group))"
|
||||
>
|
||||
{{
|
||||
capabilityGroupAllSelected(group)
|
||||
? $t('integrations.api.apiKeyCapabilityClearGroup')
|
||||
: $t('integrations.api.apiKeyCapabilitySelectGroup')
|
||||
}}
|
||||
</t-button>
|
||||
</div>
|
||||
<div class="api-key-capability-group__items">
|
||||
<div
|
||||
v-for="capability in group.capabilities"
|
||||
:key="capability.value"
|
||||
class="api-key-capability-item"
|
||||
>
|
||||
<t-checkbox
|
||||
:model-value="capabilitySelections[capability.value]"
|
||||
@change="handleCapabilityChange(capability.value, $event)"
|
||||
>
|
||||
{{ $t(capability.labelKey) }}
|
||||
</t-checkbox>
|
||||
<p class="scope-hint">{{ $t(capability.hintKey) }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!apiKeyRoleIsOwner" class="api-key-dialog-row">
|
||||
<div v-if="apiKeyKnowledgeScopeApplies" class="api-key-dialog-row">
|
||||
<div class="api-key-dialog-row__label">
|
||||
<label>{{ $t('integrations.api.apiKeyKnowledgeScope') }}</label>
|
||||
</div>
|
||||
@@ -502,18 +543,7 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="api-key-create-footer">
|
||||
<div class="api-key-create-footer__actions">
|
||||
<t-button variant="outline" size="small" @click="apiKeyDialogVisible = false">
|
||||
{{ $t('common.cancel') }}
|
||||
</t-button>
|
||||
<t-button theme="primary" size="small" :loading="apiKeyCreating" @click="createScopedAPIKey">
|
||||
{{ $t('integrations.api.createApiKey') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</t-dialog>
|
||||
</SettingDrawer>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
@@ -535,7 +565,7 @@ import {
|
||||
type APIPrincipalConfig,
|
||||
type APIPrincipalMode,
|
||||
type TenantAPIKey,
|
||||
type TenantAPIKeyRole,
|
||||
type TenantAPIKeyCapability,
|
||||
} from '@/api/tenant'
|
||||
import { listKnowledgeBases } from '@/api/knowledge-base'
|
||||
import { getApiBaseUrl } from '@/utils/api-base'
|
||||
@@ -580,66 +610,180 @@ const form = reactive({
|
||||
require_direct_header: false,
|
||||
})
|
||||
|
||||
type ApiKeyAccessRole = 'viewer' | 'contributor' | 'admin' | 'owner'
|
||||
type ApiKeyCapabilityOption = {
|
||||
value: TenantAPIKeyCapability
|
||||
labelKey: string
|
||||
hintKey: string
|
||||
}
|
||||
type ApiKeyCapabilityGroup = {
|
||||
key: string
|
||||
labelKey: string
|
||||
capabilities: ApiKeyCapabilityOption[]
|
||||
}
|
||||
|
||||
const API_KEY_CAPABILITIES: TenantAPIKeyCapability[] = [
|
||||
'retrieve',
|
||||
'chat',
|
||||
'read_agents',
|
||||
'ingest',
|
||||
'manage_kbs',
|
||||
'message_history',
|
||||
'manage_agents',
|
||||
'manage_mcp_services',
|
||||
'manage_datasources',
|
||||
'manage_models',
|
||||
'manage_vector_stores',
|
||||
'manage_web_search',
|
||||
'manage_channels',
|
||||
'run_evaluations',
|
||||
'manage_tenant_settings',
|
||||
]
|
||||
|
||||
const DEFAULT_API_KEY_CAPABILITIES = new Set<TenantAPIKeyCapability>(['retrieve', 'chat', 'read_agents'])
|
||||
const KB_SCOPED_CAPABILITIES = new Set<TenantAPIKeyCapability>([
|
||||
'retrieve',
|
||||
'chat',
|
||||
'ingest',
|
||||
'manage_kbs',
|
||||
'manage_agents',
|
||||
'manage_datasources',
|
||||
])
|
||||
|
||||
const apiKeyCapabilityGroups: ApiKeyCapabilityGroup[] = [
|
||||
{
|
||||
key: 'knowledge',
|
||||
labelKey: 'integrations.api.apiKeyCapabilityGroupKnowledge',
|
||||
capabilities: [
|
||||
{ value: 'retrieve', labelKey: 'integrations.api.capabilityRetrieve', hintKey: 'integrations.api.capabilityRetrieveHint' },
|
||||
{ value: 'chat', labelKey: 'integrations.api.capabilityChat', hintKey: 'integrations.api.capabilityChatHint' },
|
||||
{ value: 'ingest', labelKey: 'integrations.api.capabilityIngest', hintKey: 'integrations.api.capabilityIngestHint' },
|
||||
{ value: 'manage_kbs', labelKey: 'integrations.api.capabilityManageKbs', hintKey: 'integrations.api.capabilityManageKbsHint' },
|
||||
{ value: 'message_history', labelKey: 'integrations.api.capabilityMessageHistory', hintKey: 'integrations.api.capabilityMessageHistoryHint' },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'automation',
|
||||
labelKey: 'integrations.api.apiKeyCapabilityGroupAutomation',
|
||||
capabilities: [
|
||||
{ value: 'read_agents', labelKey: 'integrations.api.capabilityReadAgents', hintKey: 'integrations.api.capabilityReadAgentsHint' },
|
||||
{ value: 'manage_agents', labelKey: 'integrations.api.capabilityManageAgents', hintKey: 'integrations.api.capabilityManageAgentsHint' },
|
||||
{ value: 'manage_mcp_services', labelKey: 'integrations.api.capabilityManageMcpServices', hintKey: 'integrations.api.capabilityManageMcpServicesHint' },
|
||||
{ value: 'manage_datasources', labelKey: 'integrations.api.capabilityManageDatasources', hintKey: 'integrations.api.capabilityManageDatasourcesHint' },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'tenant',
|
||||
labelKey: 'integrations.api.apiKeyCapabilityGroupTenant',
|
||||
capabilities: [
|
||||
{ value: 'manage_models', labelKey: 'integrations.api.capabilityManageModels', hintKey: 'integrations.api.capabilityManageModelsHint' },
|
||||
{ value: 'manage_vector_stores', labelKey: 'integrations.api.capabilityManageVectorStores', hintKey: 'integrations.api.capabilityManageVectorStoresHint' },
|
||||
{ value: 'manage_web_search', labelKey: 'integrations.api.capabilityManageWebSearch', hintKey: 'integrations.api.capabilityManageWebSearchHint' },
|
||||
{ value: 'manage_channels', labelKey: 'integrations.api.capabilityManageChannels', hintKey: 'integrations.api.capabilityManageChannelsHint' },
|
||||
{ value: 'run_evaluations', labelKey: 'integrations.api.capabilityRunEvaluations', hintKey: 'integrations.api.capabilityRunEvaluationsHint' },
|
||||
{ value: 'manage_tenant_settings', labelKey: 'integrations.api.capabilityManageTenantSettings', hintKey: 'integrations.api.capabilityManageTenantSettingsHint' },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
const capabilitySelections = reactive<Record<TenantAPIKeyCapability, boolean>>(
|
||||
API_KEY_CAPABILITIES.reduce((acc, capability) => {
|
||||
acc[capability] = DEFAULT_API_KEY_CAPABILITIES.has(capability)
|
||||
return acc
|
||||
}, {} as Record<TenantAPIKeyCapability, boolean>),
|
||||
)
|
||||
|
||||
const apiKeyForm = reactive({
|
||||
name: '',
|
||||
role: 'viewer' as ApiKeyAccessRole,
|
||||
knowledge_base_ids: [] as string[],
|
||||
// Tenant-full keys already cover every capability. Scoped keys default to
|
||||
// retrieval + chat + agent reads so a fresh integration can ask questions
|
||||
// and present an agent picker immediately.
|
||||
tenant_full_enabled: false,
|
||||
})
|
||||
|
||||
// The role picker is presented as two levels: a top-level access type
|
||||
// (knowledge-base vs. full tenant) and, for knowledge-base keys, a permission
|
||||
// level (viewer/contributor/admin). Owner is a full-access key, for which the
|
||||
// KB scope is meaningless and hidden.
|
||||
const apiKeyRoleIsOwner = computed(() => apiKeyForm.role === 'owner')
|
||||
type ApiKeyAccessType = 'kb' | 'tenant'
|
||||
const apiKeyAccessType = ref<ApiKeyAccessType>('kb')
|
||||
// Remember the last knowledge-base permission level so toggling back from
|
||||
// "tenant full" restores the user's previous choice instead of resetting.
|
||||
let lastKbRole: ApiKeyAccessRole = 'viewer'
|
||||
|
||||
watch(apiKeyAccessType, (type) => {
|
||||
if (type === 'tenant') {
|
||||
apiKeyForm.role = 'owner'
|
||||
apiKeyForm.knowledge_base_ids = []
|
||||
} else if (apiKeyForm.role === 'owner') {
|
||||
apiKeyForm.role = lastKbRole === 'owner' ? 'viewer' : lastKbRole
|
||||
}
|
||||
})
|
||||
|
||||
watch(
|
||||
() => apiKeyForm.role,
|
||||
(role) => {
|
||||
if (role !== 'owner') {
|
||||
lastKbRole = role
|
||||
}
|
||||
const apiKeyFullAccessEnabled = computed(() => apiKeyForm.tenant_full_enabled)
|
||||
const apiKeyAccessMode = computed<'scoped' | 'full'>({
|
||||
get: () => (apiKeyForm.tenant_full_enabled ? 'full' : 'scoped'),
|
||||
set: (value) => {
|
||||
apiKeyForm.tenant_full_enabled = value === 'full'
|
||||
},
|
||||
)
|
||||
})
|
||||
const selectedCapabilityValues = computed(() => API_KEY_CAPABILITIES.filter((capability) => capabilitySelections[capability]))
|
||||
const apiKeyKnowledgeScopeApplies = computed(() => (
|
||||
!apiKeyFullAccessEnabled.value
|
||||
&& selectedCapabilityValues.value.some((capability) => KB_SCOPED_CAPABILITIES.has(capability))
|
||||
))
|
||||
|
||||
function formatApiKeyAccessRoleLabel(role: ApiKeyAccessRole | TenantAPIKeyRole | undefined): string {
|
||||
const normalized = (role ?? 'viewer') as ApiKeyAccessRole
|
||||
const labels: Record<ApiKeyAccessRole, string> = {
|
||||
viewer: t('integrations.api.accessRoleViewer'),
|
||||
contributor: t('integrations.api.accessRoleContributor'),
|
||||
admin: t('integrations.api.accessRoleAdmin'),
|
||||
owner: t('integrations.api.accessRoleOwner'),
|
||||
watch(() => apiKeyForm.tenant_full_enabled, (enabled) => {
|
||||
if (enabled) {
|
||||
apiKeyForm.knowledge_base_ids = []
|
||||
}
|
||||
return labels[normalized] ?? labels.viewer
|
||||
})
|
||||
|
||||
watch(apiKeyKnowledgeScopeApplies, (applies) => {
|
||||
if (!applies) {
|
||||
apiKeyForm.knowledge_base_ids = []
|
||||
}
|
||||
})
|
||||
|
||||
function selectedCapabilities(): TenantAPIKeyCapability[] {
|
||||
return selectedCapabilityValues.value
|
||||
}
|
||||
|
||||
const apiKeyFormRoleDesc = computed(() => {
|
||||
switch (apiKeyForm.role) {
|
||||
case 'owner':
|
||||
return t('integrations.api.accessRoleOwnerDesc')
|
||||
case 'admin':
|
||||
return t('integrations.api.accessRoleAdminDesc')
|
||||
case 'contributor':
|
||||
return t('integrations.api.accessRoleContributorDesc')
|
||||
default:
|
||||
return t('integrations.api.accessRoleViewerDesc')
|
||||
function setCapabilitySelected(capability: TenantAPIKeyCapability, selected: boolean) {
|
||||
capabilitySelections[capability] = selected
|
||||
}
|
||||
|
||||
function handleCapabilityChange(capability: TenantAPIKeyCapability, checked: unknown) {
|
||||
setCapabilitySelected(capability, Boolean(checked))
|
||||
}
|
||||
|
||||
function capabilityGroupAllSelected(group: ApiKeyCapabilityGroup): boolean {
|
||||
return group.capabilities.every((capability) => capabilitySelections[capability.value])
|
||||
}
|
||||
|
||||
function toggleCapabilityGroup(group: ApiKeyCapabilityGroup, selected: boolean) {
|
||||
group.capabilities.forEach((capability) => {
|
||||
capabilitySelections[capability.value] = selected
|
||||
})
|
||||
}
|
||||
|
||||
// Full-access keys already cover every capability, so no capability badges for them.
|
||||
function keyCapabilityLabels(key: TenantAPIKey): string[] {
|
||||
if (key.full_access) return []
|
||||
const labels: Record<TenantAPIKeyCapability, string> = {
|
||||
retrieve: t('integrations.api.capabilityRetrieve'),
|
||||
chat: t('integrations.api.capabilityChat'),
|
||||
read_agents: t('integrations.api.capabilityReadAgents'),
|
||||
ingest: t('integrations.api.capabilityIngest'),
|
||||
manage_kbs: t('integrations.api.capabilityManageKbs'),
|
||||
manage_agents: t('integrations.api.capabilityManageAgents'),
|
||||
message_history: t('integrations.api.capabilityMessageHistory'),
|
||||
manage_models: t('integrations.api.capabilityManageModels'),
|
||||
manage_mcp_services: t('integrations.api.capabilityManageMcpServices'),
|
||||
manage_datasources: t('integrations.api.capabilityManageDatasources'),
|
||||
manage_channels: t('integrations.api.capabilityManageChannels'),
|
||||
manage_vector_stores: t('integrations.api.capabilityManageVectorStores'),
|
||||
manage_web_search: t('integrations.api.capabilityManageWebSearch'),
|
||||
run_evaluations: t('integrations.api.capabilityRunEvaluations'),
|
||||
manage_tenant_settings: t('integrations.api.capabilityManageTenantSettings'),
|
||||
}
|
||||
})
|
||||
return (key.capabilities ?? [])
|
||||
.map((c) => labels[c])
|
||||
.filter((label): label is string => Boolean(label))
|
||||
}
|
||||
|
||||
function formatApiKeyCapabilitiesTitle(key: TenantAPIKey): string {
|
||||
if (key.full_access) return t('integrations.api.capabilityTenantFull')
|
||||
const labels = keyCapabilityLabels(key)
|
||||
return labels.length > 0 ? labels.join(' / ') : t('integrations.api.apiKeyScopedAccess')
|
||||
}
|
||||
|
||||
function formatApiKeyAccessModeLabel(key: TenantAPIKey): string {
|
||||
return key.full_access
|
||||
? t('integrations.api.capabilityTenantFull')
|
||||
: t('integrations.api.apiKeyScopedAccess')
|
||||
}
|
||||
|
||||
type PlaygroundStatus = '' | 'running' | 'success' | 'failed' | 'stopped'
|
||||
|
||||
@@ -1170,10 +1314,11 @@ function openApiDoc() {
|
||||
|
||||
function openCreateAPIKeyDialog() {
|
||||
apiKeyForm.name = ''
|
||||
apiKeyForm.role = 'viewer'
|
||||
apiKeyForm.knowledge_base_ids = []
|
||||
apiKeyAccessType.value = 'kb'
|
||||
lastKbRole = 'viewer'
|
||||
apiKeyForm.tenant_full_enabled = false
|
||||
API_KEY_CAPABILITIES.forEach((capability) => {
|
||||
capabilitySelections[capability] = DEFAULT_API_KEY_CAPABILITIES.has(capability)
|
||||
})
|
||||
apiKeyDialogVisible.value = true
|
||||
void loadKnowledgeBaseOptions()
|
||||
}
|
||||
@@ -1187,9 +1332,11 @@ async function createScopedAPIKey() {
|
||||
try {
|
||||
const resp = await createTenantAPIKey(tenantId.value, {
|
||||
name: apiKeyForm.name.trim(),
|
||||
role: apiKeyForm.role,
|
||||
// Owner keys are full-access; KB scoping does not apply to them.
|
||||
knowledge_base_ids: apiKeyRoleIsOwner.value ? [] : apiKeyForm.knowledge_base_ids,
|
||||
full_access: apiKeyFullAccessEnabled.value,
|
||||
// KB scoping only applies to capabilities that touch knowledge bases.
|
||||
knowledge_base_ids: apiKeyKnowledgeScopeApplies.value ? apiKeyForm.knowledge_base_ids : [],
|
||||
// Capabilities only matter below full access; full access already covers them all.
|
||||
capabilities: apiKeyFullAccessEnabled.value ? [] : selectedCapabilities(),
|
||||
})
|
||||
if (!resp.success || !resp.data?.api_key) {
|
||||
throw new Error(resp.message || t('integrations.api.createApiKeyFailed'))
|
||||
@@ -1438,44 +1585,6 @@ onMounted(async () => {
|
||||
onBeforeUnmount(stopPlayground)
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.api-key-create-dialog {
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.api-key-create-dialog .t-dialog__header {
|
||||
min-height: auto;
|
||||
padding: 20px 20px 0;
|
||||
}
|
||||
|
||||
.api-key-create-dialog .t-dialog__body {
|
||||
padding: 0 20px 20px;
|
||||
}
|
||||
|
||||
.api-key-create-dialog .t-dialog__close {
|
||||
top: 16px;
|
||||
right: 16px;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: 4px;
|
||||
color: var(--td-text-color-secondary);
|
||||
transition: background 0.18s ease;
|
||||
}
|
||||
|
||||
.api-key-create-dialog .t-dialog__close:hover {
|
||||
color: var(--td-text-color-primary);
|
||||
background: var(--td-bg-color-container-hover);
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.api-key-create-dialog {
|
||||
width: calc(100vw - 24px) !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style scoped lang="less">
|
||||
.api-integration {
|
||||
width: 100%;
|
||||
@@ -1657,22 +1766,22 @@ onBeforeUnmount(stopPlayground)
|
||||
|
||||
th:nth-child(2),
|
||||
td:nth-child(2) {
|
||||
width: 26%;
|
||||
width: 22%;
|
||||
}
|
||||
|
||||
th:nth-child(3),
|
||||
td:nth-child(3) {
|
||||
width: 15%;
|
||||
width: 24%;
|
||||
}
|
||||
|
||||
th:nth-child(4),
|
||||
td:nth-child(4) {
|
||||
width: 18%;
|
||||
width: 16%;
|
||||
}
|
||||
|
||||
th:nth-child(5),
|
||||
td:nth-child(5) {
|
||||
width: 15%;
|
||||
width: 12%;
|
||||
}
|
||||
|
||||
th:nth-child(6),
|
||||
@@ -1720,6 +1829,100 @@ onBeforeUnmount(stopPlayground)
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.api-key-access-cell {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 7px;
|
||||
}
|
||||
|
||||
.api-key-access-mode {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
max-width: 100%;
|
||||
height: 24px;
|
||||
padding: 0 9px;
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: 6px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-text-color-primary);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
line-height: 22px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.api-key-access-mode--full {
|
||||
border-color: color-mix(in srgb, var(--td-brand-color) 28%, transparent);
|
||||
background: color-mix(in srgb, var(--td-brand-color) 10%, var(--td-bg-color-container));
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
|
||||
.api-key-capability-chips {
|
||||
display: flex;
|
||||
max-width: 100%;
|
||||
flex-wrap: wrap;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.api-key-capability-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
max-width: 100%;
|
||||
height: 22px;
|
||||
padding: 0 8px;
|
||||
border-radius: 6px;
|
||||
background: color-mix(in srgb, var(--td-success-color) 10%, var(--td-bg-color-container));
|
||||
color: var(--td-success-color);
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
line-height: 20px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.api-key-capability-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.api-key-capability-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 10px 0 2px;
|
||||
}
|
||||
|
||||
.api-key-capability-group + .api-key-capability-group {
|
||||
border-top: 1px solid var(--td-component-stroke);
|
||||
}
|
||||
|
||||
.api-key-capability-group__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
min-height: 24px;
|
||||
color: var(--td-text-color-primary);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.api-key-capability-group__items {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.api-key-capability-item .scope-hint {
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.api-key-knowledge-scope,
|
||||
.api-key-created-at {
|
||||
display: block;
|
||||
@@ -1734,55 +1937,10 @@ onBeforeUnmount(stopPlayground)
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0;
|
||||
margin-top: 16px;
|
||||
padding: 0;
|
||||
border-bottom: 1px solid var(--td-component-stroke);
|
||||
}
|
||||
|
||||
.api-key-create-heading {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
padding-right: 28px;
|
||||
}
|
||||
|
||||
.api-key-create-heading-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.api-key-create-heading-mark {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
color: var(--td-brand-color);
|
||||
line-height: 0;
|
||||
|
||||
:deep(.t-icon) {
|
||||
display: inline-flex;
|
||||
}
|
||||
}
|
||||
|
||||
.api-key-create-title {
|
||||
color: var(--td-text-color-primary);
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
line-height: 22px;
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
|
||||
.api-key-create-desc {
|
||||
margin: 0;
|
||||
color: var(--td-text-color-placeholder);
|
||||
font-size: 13px;
|
||||
font-weight: 400;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.api-key-dialog-row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -1846,90 +2004,13 @@ onBeforeUnmount(stopPlayground)
|
||||
}
|
||||
}
|
||||
|
||||
.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-role-hint {
|
||||
.scope-hint {
|
||||
margin: 8px 0 0;
|
||||
color: var(--td-text-color-placeholder);
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.scope-help {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
padding: 8px 10px;
|
||||
border-radius: 4px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
|
||||
&--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: 12px;
|
||||
line-height: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
.api-key-create-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
padding-top: 14px;
|
||||
}
|
||||
|
||||
.api-key-create-footer__actions {
|
||||
display: flex;
|
||||
flex: 0 0 auto;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.principal-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
Reference in New Issue
Block a user