Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix(web): protect workspace admins in resource access (#43118)

Wu Tianwei0fec636da517
diff --git a/web/app/components/access-rules-editor/__tests__/index.spec.tsx b/web/app/components/access-rules-editor/__tests__/index.spec.tsx
index 711130972c5..dc146652176 100644
--- a/web/app/components/access-rules-editor/__tests__/index.spec.tsx
+++ b/web/app/components/access-rules-editor/__tests__/index.spec.tsx
@@ -378,6 +378,90 @@ describe('AccessRulesEditor', () => {
},
)
+ it.each([
+ ['app', 'admin', 'Workspace Admin'],
+ ['dataset', '', 'admin'],
+ ] as const)(
+ 'should identify and protect a workspace admin in %s access',
+ async (resourceType, roleTag, roleName) => {
+ const user = userEvent.setup()
+ const adminSetting: ResourceUserAccessSetting = {
+ ...createUserAccessSetting(resourceType),
+ account: {
+ account_id: 'workspace-admin',
+ account_name: 'Workspace Admin',
+ email: '[email protected]',
+ },
+ roles: [
+ {
+ id: 'admin-role',
+ type: 'workspace',
+ category: 'global_system_default',
+ name: roleName,
+ is_builtin: true,
+ permission_keys: [],
+ role_tag: roleTag,
+ },
+ ],
+ }
+ const memberSetting: ResourceUserAccessSetting = {
+ ...createDefaultUserAccessSetting(),
+ account: {
+ account_id: 'account-2',
+ account_name: 'Mia',
+ email: '[email protected]',
+ },
+ }
+ const onUserAccessPoliciesChange = vi.fn()
+ const onRemoveAccessPolicyMemberBinding = vi.fn()
+ const onBatchRemoveAccessPolicyMemberBindings = vi.fn().mockResolvedValue(undefined)
+
+ render(
+ <AccessRulesEditor
+ rules={[createRule(resourceType)]}
+ userAccessSettings={[adminSetting, memberSetting]}
+ isLoadingRules={false}
+ isLoadingUserAccessSettings={false}
+ automaticIncludeWorkspaceMembers={false}
+ isUpdatingAutomaticIncludeWorkspaceMembers={false}
+ updatingAccountId={null}
+ onUserAccessPoliciesChange={onUserAccessPoliciesChange}
+ onRemoveAccessPolicyMemberBinding={onRemoveAccessPolicyMemberBinding}
+ onBatchRemoveAccessPolicyMemberBindings={onBatchRemoveAccessPolicyMemberBindings}
+ />,
+ )
+
+ const adminRow = screen.getByRole('row', { name: /Workspace Admin/ })
+ expect(within(adminRow).getByText('permission.accessRule.workspaceAdmin')).toBeInTheDocument()
+ expect(within(adminRow).getByRole('checkbox', { name: 'Workspace Admin' })).toHaveAttribute(
+ 'aria-disabled',
+ 'true',
+ )
+ expect(
+ within(adminRow).getByLabelText(/permission\.accessRule\.exceptionPermissionFor/),
+ ).toBeDisabled()
+ expect(
+ within(adminRow).getByRole('button', { name: 'common.operation.remove' }),
+ ).toBeDisabled()
+
+ await user.click(screen.getByRole('checkbox', { name: 'common.operation.selectAll' }))
+ expect(screen.getByRole('checkbox', { name: 'Workspace Admin' })).not.toBeChecked()
+ expect(screen.getByRole('checkbox', { name: 'Mia' })).toBeChecked()
+
+ await user.click(screen.getByRole('button', { name: 'common.operation.delete' }))
+ const dialog = screen.getByRole('alertdialog', {
+ name: 'permission.accessRule.batchRemoveTitle',
+ })
+ await user.click(within(dialog).getByRole('button', { name: 'common.operation.sure' }))
+
+ expect(onBatchRemoveAccessPolicyMemberBindings).toHaveBeenCalledWith([
+ { accessPolicyId: 'default', accountIds: ['account-2'] },
+ ])
+ expect(onUserAccessPoliciesChange).not.toHaveBeenCalled()
+ expect(onRemoveAccessPolicyMemberBinding).not.toHaveBeenCalled()
+ },
+ )
+
it('should navigate through member pages and change the page size', async () => {
const user = userEvent.setup()
const onPageChange = vi.fn()
diff --git a/web/app/components/access-rules-editor/index.tsx b/web/app/components/access-rules-editor/index.tsx
index 8f62664b73c..2daccd8ffc9 100644
--- a/web/app/components/access-rules-editor/index.tsx
+++ b/web/app/components/access-rules-editor/index.tsx
@@ -16,6 +16,7 @@ import AddAccessSubjectPopover from './add-access-subject-popover'
import AutomaticIncludeWorkspaceMembersSection from './automatic-include-workspace-members-section'
import AccessRulesBatchAction from './batch-action'
import { ACCESS_RULE_TABLE_GRID, DEFAULT_ACCESS_POLICY_ID } from './constants'
+import { isWorkspaceAdminRole } from './is-workspace-admin-role'
import UserAccessPolicyRow from './user-access-policy-row'
export type AccessPolicyMemberBindingRemoval = {
@@ -97,7 +98,9 @@ function AccessRulesEditor({
for (const setting of userAccessSettings) {
const accountId = setting.account.account_id
const isWorkspaceOwner = setting.roles?.some((role) => role.role_tag === 'owner')
- if (accountId === maintainerId || isWorkspaceOwner) accountIds.add(accountId)
+ const isWorkspaceAdmin = setting.roles?.some(isWorkspaceAdminRole)
+ if (accountId === maintainerId || isWorkspaceOwner || isWorkspaceAdmin)
+ accountIds.add(accountId)
}
return accountIds
diff --git a/web/app/components/access-rules-editor/is-workspace-admin-role.ts b/web/app/components/access-rules-editor/is-workspace-admin-role.ts
new file mode 100644
index 00000000000..a42668dab21
--- /dev/null
+++ b/web/app/components/access-rules-editor/is-workspace-admin-role.ts
@@ -0,0 +1,12 @@
+import type { RbacRole } from '@dify/contracts/api/console/workspaces/types.gen'
+
+export const isWorkspaceAdminRole = (role: RbacRole): boolean => {
+ if (role.type !== 'workspace') return false
+
+ return (
+ role.role_tag === 'admin' ||
+ (role.is_builtin === true &&
+ role.category === 'global_system_default' &&
+ role.name.toLowerCase() === 'admin')
+ )
+}
diff --git a/web/app/components/access-rules-editor/user-access-policy-row.tsx b/web/app/components/access-rules-editor/user-access-policy-row.tsx
index 8f1804964d2..eea9df6bcbd 100644
--- a/web/app/components/access-rules-editor/user-access-policy-row.tsx
+++ b/web/app/components/access-rules-editor/user-access-policy-row.tsx
@@ -16,6 +16,7 @@ import {
import { memo, useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import { ACCESS_RULE_TABLE_GRID, DEFAULT_ACCESS_POLICY_ID } from './constants'
+import { isWorkspaceAdminRole } from './is-workspace-admin-role'
type PolicyOption = {
id: string
@@ -63,6 +64,7 @@ function UserAccessPolicyRow({
const defaultAccessPolicyName = t(($) => $['accessRule.defaultPermission'], { ns: 'permission' })
const accountEmail = setting.account.email || accountName
const isWorkspaceOwner = setting.roles?.some((role) => role.role_tag === 'owner')
+ const isWorkspaceAdmin = setting.roles?.some(isWorkspaceAdminRole)
const handlePolicyChange = useCallback(
(nextPolicyId: string | null) => {
@@ -107,6 +109,11 @@ function UserAccessPolicyRow({
{t(($) => $['accessRule.workspaceOwner'], { ns: 'permission' })}
</span>
)}
+ {isWorkspaceAdmin && (
+ <span className="max-w-32 shrink-0 truncate rounded-[5px] border border-text-accent-secondary px-1 py-0.5 system-2xs-medium-uppercase text-text-accent-secondary">
+ {t(($) => $['accessRule.workspaceAdmin'], { ns: 'permission' })}
+ </span>
+ )}
</div>
<p className="truncate system-xs-regular text-text-tertiary">{accountEmail}</p>
</div>
diff --git a/web/features/agent-v2/agent-detail/access-config/__tests__/page.spec.tsx b/web/features/agent-v2/agent-detail/access-config/__tests__/page.spec.tsx
index aa596bdafaf..f7504e6a27e 100644
--- a/web/features/agent-v2/agent-detail/access-config/__tests__/page.spec.tsx
+++ b/web/features/agent-v2/agent-detail/access-config/__tests__/page.spec.tsx
@@ -206,6 +206,48 @@ describe('AgentAccessConfigPage', () => {
])
})
+ it('shows and protects a workspace admin in resource access', async () => {
+ const admin = zResourceUserAccessPolicies.parse({
+ ...createUser('admin', 'Workspace Admin'),
+ roles: [
+ {
+ id: 'admin-role',
+ type: 'workspace',
+ category: 'global_system_default',
+ name: 'Admin',
+ is_builtin: true,
+ role_tag: 'admin',
+ },
+ ],
+ })
+ setup({ users: [admin, createUser('mia', 'Mia')] })
+
+ const adminRow = screen.getByRole('row', { name: /Workspace Admin/ })
+ expect(within(adminRow).getByText('permission.accessRule.workspaceAdmin')).toBeInTheDocument()
+ expect(within(adminRow).getByRole('checkbox', { name: 'Workspace Admin' })).toHaveAttribute(
+ 'aria-disabled',
+ 'true',
+ )
+ expect(within(adminRow).getByRole('combobox')).toBeDisabled()
+ expect(within(adminRow).getByRole('button', { name: 'common.operation.remove' })).toBeDisabled()
+
+ await userEvent.click(screen.getByRole('checkbox', { name: 'common.operation.selectAll' }))
+ expect(within(adminRow).getByRole('checkbox', { name: 'Workspace Admin' })).not.toBeChecked()
+ expect(screen.getByRole('checkbox', { name: 'Mia' })).toBeChecked()
+
+ await userEvent.click(screen.getByRole('button', { name: 'common.operation.delete' }))
+ await userEvent.click(
+ within(screen.getByRole('alertdialog')).getByRole('button', {
+ name: 'common.operation.sure',
+ }),
+ )
+ await waitFor(() => expect(screen.queryByRole('row', { name: /Mia/ })).not.toBeInTheDocument())
+ expect(screen.getByRole('row', { name: /Workspace Admin/ })).toBeInTheDocument()
+ const removals = sent.filter((req) => req.method === 'DELETE')
+ expect(removals).toHaveLength(1)
+ expect(await removals[0]!.json()).toEqual({ account_ids: ['mia'] })
+ })
+
it('returns to the previous page after removing its last member', async () => {
const users = Array.from({ length: RESOURCE_ACCESS_SETTINGS_PAGE_SIZE + 1 }, (_, i) =>
createUser(`user-${i}`, `Member ${i}`),
diff --git a/web/i18n/locales/ar-TN/permission.json b/web/i18n/locales/ar-TN/permission.json
index 934948c1b2e..2b135ed385b 100644
--- a/web/i18n/locales/ar-TN/permission.json
+++ b/web/i18n/locales/ar-TN/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} مجموعة أذونات",
"accessRule.summary_other": "{{count}} مجموعات أذونات",
"accessRule.updated": "تم تحديث قاعدة الوصول بنجاح",
+ "accessRule.workspaceAdmin": "مدير مساحة العمل",
"accessRule.workspaceOwner": "مالك مساحة العمل",
"common.duplicateAction": "تكرار",
"group.agent": "الوكلاء",
diff --git a/web/i18n/locales/az-AZ/permission.json b/web/i18n/locales/az-AZ/permission.json
index 3b2a12e9219..3fa5e3d161c 100644
--- a/web/i18n/locales/az-AZ/permission.json
+++ b/web/i18n/locales/az-AZ/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} icazə dəsti",
"accessRule.summary_other": "{{count}} icazə dəsti",
"accessRule.updated": "Giriş qaydası uğurla yeniləndi",
+ "accessRule.workspaceAdmin": "İş sahəsinin administratoru",
"accessRule.workspaceOwner": "İş sahəsinin sahibi",
"common.duplicateAction": "Nüsxə yarat",
"group.agent": "Agentlər",
diff --git a/web/i18n/locales/de-DE/permission.json b/web/i18n/locales/de-DE/permission.json
index f041ea7388e..6cd358b3bc2 100644
--- a/web/i18n/locales/de-DE/permission.json
+++ b/web/i18n/locales/de-DE/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} Berechtigungssatz",
"accessRule.summary_other": "{{count}} Berechtigungssätze",
"accessRule.updated": "Zugriffsregel erfolgreich aktualisiert",
+ "accessRule.workspaceAdmin": "Workspace-Administrator",
"accessRule.workspaceOwner": "Workspace-Inhaber",
"common.duplicateAction": "Duplizieren",
"group.agent": "Agenten",
diff --git a/web/i18n/locales/en-US/permission.json b/web/i18n/locales/en-US/permission.json
index 22c7f48c5be..ee3ba4f0794 100644
--- a/web/i18n/locales/en-US/permission.json
+++ b/web/i18n/locales/en-US/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} permission set",
"accessRule.summary_other": "{{count}} permission sets",
"accessRule.updated": "Access rule updated successfully",
+ "accessRule.workspaceAdmin": "Workspace Admin",
"accessRule.workspaceOwner": "Workspace Owner",
"common.duplicateAction": "Duplicate",
"group.agent": "Agents",
diff --git a/web/i18n/locales/es-ES/permission.json b/web/i18n/locales/es-ES/permission.json
index 163de1bd87a..99883594287 100644
--- a/web/i18n/locales/es-ES/permission.json
+++ b/web/i18n/locales/es-ES/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} conjunto de permisos",
"accessRule.summary_other": "{{count}} conjuntos de permisos",
"accessRule.updated": "Regla de acceso actualizada correctamente",
+ "accessRule.workspaceAdmin": "Administrador del espacio de trabajo",
"accessRule.workspaceOwner": "Propietario del espacio de trabajo",
"common.duplicateAction": "Duplicar",
"group.agent": "Agentes",
diff --git a/web/i18n/locales/fa-IR/permission.json b/web/i18n/locales/fa-IR/permission.json
index 4b957ed4d88..8a1d3f6569d 100644
--- a/web/i18n/locales/fa-IR/permission.json
+++ b/web/i18n/locales/fa-IR/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} مجموعه مجوز",
"accessRule.summary_other": "{{count}} مجموعه مجوز",
"accessRule.updated": "قانون دسترسی با موفقیت به‌روزرسانی شد",
+ "accessRule.workspaceAdmin": "مدیر فضای کاری",
"accessRule.workspaceOwner": "مالک فضای کاری",
"common.duplicateAction": "تکثیر",
"group.agent": "عامل‌ها",
diff --git a/web/i18n/locales/fr-FR/permission.json b/web/i18n/locales/fr-FR/permission.json
index 0feceabe3c9..36836bce1d9 100644
--- a/web/i18n/locales/fr-FR/permission.json
+++ b/web/i18n/locales/fr-FR/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} ensemble d'autorisations",
"accessRule.summary_other": "{{count}} ensembles d'autorisations",
"accessRule.updated": "Règle d'accès mise à jour avec succès",
+ "accessRule.workspaceAdmin": "Administrateur de l’espace de travail",
"accessRule.workspaceOwner": "Propriétaire de l’espace de travail",
"common.duplicateAction": "Dupliquer",
"group.agent": "Agents",
diff --git a/web/i18n/locales/hi-IN/permission.json b/web/i18n/locales/hi-IN/permission.json
index 9cb3fdd0b54..49d68981997 100644
--- a/web/i18n/locales/hi-IN/permission.json
+++ b/web/i18n/locales/hi-IN/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} अनुमति सेट",
"accessRule.summary_other": "{{count}} अनुमति सेट",
"accessRule.updated": "एक्सेस नियम सफलतापूर्वक अपडेट किया गया",
+ "accessRule.workspaceAdmin": "वर्कस्पेस व्यवस्थापक",
"accessRule.workspaceOwner": "वर्कस्पेस का मालिक",
"common.duplicateAction": "डुप्लिकेट करें",
"group.agent": "एजेंट",
diff --git a/web/i18n/locales/id-ID/permission.json b/web/i18n/locales/id-ID/permission.json
index ec11135070e..8f6b6f982eb 100644
--- a/web/i18n/locales/id-ID/permission.json
+++ b/web/i18n/locales/id-ID/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} set izin",
"accessRule.summary_other": "{{count}} set izin",
"accessRule.updated": "Aturan akses berhasil diperbarui",
+ "accessRule.workspaceAdmin": "Admin Workspace",
"accessRule.workspaceOwner": "Pemilik Workspace",
"common.duplicateAction": "Duplikat",
"group.agent": "Agen",
diff --git a/web/i18n/locales/it-IT/permission.json b/web/i18n/locales/it-IT/permission.json
index d45cb5c6082..32f78abc1fd 100644
--- a/web/i18n/locales/it-IT/permission.json
+++ b/web/i18n/locales/it-IT/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} set di permessi",
"accessRule.summary_other": "{{count}} set di permessi",
"accessRule.updated": "Regola di accesso aggiornata con successo",
+ "accessRule.workspaceAdmin": "Amministratore del workspace",
"accessRule.workspaceOwner": "Proprietario del workspace",
"common.duplicateAction": "Duplica",
"group.agent": "Agenti",
diff --git a/web/i18n/locales/ja-JP/permission.json b/web/i18n/locales/ja-JP/permission.json
index 26d18dc7728..73f4594704b 100644
--- a/web/i18n/locales/ja-JP/permission.json
+++ b/web/i18n/locales/ja-JP/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} 件の権限セット",
"accessRule.summary_other": "{{count}} 件の権限セット",
"accessRule.updated": "アクセスルールを更新しました",
+ "accessRule.workspaceAdmin": "ワークスペース管理者",
"accessRule.workspaceOwner": "ワークスペースのオーナー",
"common.duplicateAction": "複製",
"group.agent": "エージェント",
diff --git a/web/i18n/locales/ko-KR/permission.json b/web/i18n/locales/ko-KR/permission.json
index 0da49432ace..6dac8ad8006 100644
--- a/web/i18n/locales/ko-KR/permission.json
+++ b/web/i18n/locales/ko-KR/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}}개 권한 집합",
"accessRule.summary_other": "{{count}}개 권한 집합",
"accessRule.updated": "접근 규칙이 성공적으로 업데이트되었습니다",
+ "accessRule.workspaceAdmin": "워크스페이스 관리자",
"accessRule.workspaceOwner": "워크스페이스 소유자",
"common.duplicateAction": "복제",
"group.agent": "에이전트",
diff --git a/web/i18n/locales/lo-LA/permission.json b/web/i18n/locales/lo-LA/permission.json
index cfb16d624cd..47e90d0c7a5 100644
--- a/web/i18n/locales/lo-LA/permission.json
+++ b/web/i18n/locales/lo-LA/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} ຊຸດສິດ",
"accessRule.summary_other": "{{count}} ຊຸດສິດ",
"accessRule.updated": "ອັບເດດກົດລະບຽບການເຂົ້າເຖິງສຳເລັດແລ້ວ",
+ "accessRule.workspaceAdmin": "ຜູ້ດູແລພື້ນທີ່ເຮັດວຽກ",
"accessRule.workspaceOwner": "ເຈົ້າຂອງພື້ນທີ່ເຮັດວຽກ",
"common.duplicateAction": "ເຮັດສຳເນົາ",
"group.agent": "ຕົວແທນ",
diff --git a/web/i18n/locales/nl-NL/permission.json b/web/i18n/locales/nl-NL/permission.json
index 2602df5e6de..fb04cad12e5 100644
--- a/web/i18n/locales/nl-NL/permission.json
+++ b/web/i18n/locales/nl-NL/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} rechtenset",
"accessRule.summary_other": "{{count}} rechtensets",
"accessRule.updated": "Toegangsregel succesvol bijgewerkt",
+ "accessRule.workspaceAdmin": "Workspacebeheerder",
"accessRule.workspaceOwner": "Eigenaar van de workspace",
"common.duplicateAction": "Dupliceren",
"group.agent": "Agenten",
diff --git a/web/i18n/locales/pl-PL/permission.json b/web/i18n/locales/pl-PL/permission.json
index 124e4e2d46c..99bf1ffbd29 100644
--- a/web/i18n/locales/pl-PL/permission.json
+++ b/web/i18n/locales/pl-PL/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} zestaw uprawnień",
"accessRule.summary_other": "{{count}} zestawów uprawnień",
"accessRule.updated": "Pomyślnie zaktualizowano regułę dostępu",
+ "accessRule.workspaceAdmin": "Administrator obszaru roboczego",
"accessRule.workspaceOwner": "Właściciel obszaru roboczego",
"common.duplicateAction": "Duplikuj",
"group.agent": "Agenci",
diff --git a/web/i18n/locales/pt-BR/permission.json b/web/i18n/locales/pt-BR/permission.json
index 804967d985e..a50009259b9 100644
--- a/web/i18n/locales/pt-BR/permission.json
+++ b/web/i18n/locales/pt-BR/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} conjunto de permissões",
"accessRule.summary_other": "{{count}} conjuntos de permissões",
"accessRule.updated": "Regra de acesso atualizada com sucesso",
+ "accessRule.workspaceAdmin": "Administrador do workspace",
"accessRule.workspaceOwner": "Proprietário do workspace",
"common.duplicateAction": "Duplicar",
"group.agent": "Agentes",
diff --git a/web/i18n/locales/ro-RO/permission.json b/web/i18n/locales/ro-RO/permission.json
index 23acabe0b4e..7df20eeb5b1 100644
--- a/web/i18n/locales/ro-RO/permission.json
+++ b/web/i18n/locales/ro-RO/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} set de permisiuni",
"accessRule.summary_other": "{{count}} seturi de permisiuni",
"accessRule.updated": "Regula de acces a fost actualizată cu succes",
+ "accessRule.workspaceAdmin": "Administratorul spațiului de lucru",
"accessRule.workspaceOwner": "Proprietarul spațiului de lucru",
"common.duplicateAction": "Duplică",
"group.agent": "Agenți",
diff --git a/web/i18n/locales/ru-RU/permission.json b/web/i18n/locales/ru-RU/permission.json
index 7b77737087b..4cd3f6570d0 100644
--- a/web/i18n/locales/ru-RU/permission.json
+++ b/web/i18n/locales/ru-RU/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} набор прав",
"accessRule.summary_other": "{{count}} наборов прав",
"accessRule.updated": "Правило доступа успешно обновлено",
+ "accessRule.workspaceAdmin": "Администратор рабочего пространства",
"accessRule.workspaceOwner": "Владелец рабочего пространства",
"common.duplicateAction": "Дублировать",
"group.agent": "Агенты",
diff --git a/web/i18n/locales/sl-SI/permission.json b/web/i18n/locales/sl-SI/permission.json
index f04eae00883..8970da91f75 100644
--- a/web/i18n/locales/sl-SI/permission.json
+++ b/web/i18n/locales/sl-SI/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} nabor dovoljenj",
"accessRule.summary_other": "{{count}} naborov dovoljenj",
"accessRule.updated": "Pravilo za dostop uspešno posodobljeno",
+ "accessRule.workspaceAdmin": "Skrbnik delovnega prostora",
"accessRule.workspaceOwner": "Lastnik delovnega prostora",
"common.duplicateAction": "Podvoji",
"group.agent": "Agenti",
diff --git a/web/i18n/locales/th-TH/permission.json b/web/i18n/locales/th-TH/permission.json
index ffdeafef52d..fd272df312e 100644
--- a/web/i18n/locales/th-TH/permission.json
+++ b/web/i18n/locales/th-TH/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "ชุดสิทธิ์ {{count}} ชุด",
"accessRule.summary_other": "ชุดสิทธิ์ {{count}} ชุด",
"accessRule.updated": "อัปเดตกฎการเข้าถึงสําเร็จ",
+ "accessRule.workspaceAdmin": "ผู้ดูแลเวิร์กสเปซ",
"accessRule.workspaceOwner": "เจ้าของเวิร์กสเปซ",
"common.duplicateAction": "ทําซ้ํา",
"group.agent": "ตัวแทน",
diff --git a/web/i18n/locales/tr-TR/permission.json b/web/i18n/locales/tr-TR/permission.json
index 7bc6dd918c4..7ae76b90305 100644
--- a/web/i18n/locales/tr-TR/permission.json
+++ b/web/i18n/locales/tr-TR/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} izin kümesi",
"accessRule.summary_other": "{{count}} izin kümesi",
"accessRule.updated": "Erişim kuralı başarıyla güncellendi",
+ "accessRule.workspaceAdmin": "Çalışma alanı yöneticisi",
"accessRule.workspaceOwner": "Çalışma alanı sahibi",
"common.duplicateAction": "Çoğalt",
"group.agent": "Ajanlar",
diff --git a/web/i18n/locales/uk-UA/permission.json b/web/i18n/locales/uk-UA/permission.json
index 1c93455d54f..87d332cd98e 100644
--- a/web/i18n/locales/uk-UA/permission.json
+++ b/web/i18n/locales/uk-UA/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} набір дозволів",
"accessRule.summary_other": "{{count}} наборів дозволів",
"accessRule.updated": "Правило доступу успішно оновлено",
+ "accessRule.workspaceAdmin": "Адміністратор робочого простору",
"accessRule.workspaceOwner": "Власник робочого простору",
"common.duplicateAction": "Дублювати",
"group.agent": "Агенти",
diff --git a/web/i18n/locales/vi-VN/permission.json b/web/i18n/locales/vi-VN/permission.json
index 4bd0029fc16..cdc48c0ea38 100644
--- a/web/i18n/locales/vi-VN/permission.json
+++ b/web/i18n/locales/vi-VN/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} bộ quyền",
"accessRule.summary_other": "{{count}} bộ quyền",
"accessRule.updated": "Đã cập nhật quy tắc truy cập thành công",
+ "accessRule.workspaceAdmin": "Quản trị viên workspace",
"accessRule.workspaceOwner": "Chủ sở hữu workspace",
"common.duplicateAction": "Nhân bản",
"group.agent": "Tác nhân",
diff --git a/web/i18n/locales/zh-Hans/permission.json b/web/i18n/locales/zh-Hans/permission.json
index d835c66bdf3..9370a107903 100644
--- a/web/i18n/locales/zh-Hans/permission.json
+++ b/web/i18n/locales/zh-Hans/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} 个权限集",
"accessRule.summary_other": "{{count}} 个权限集",
"accessRule.updated": "访问规则已更新",
+ "accessRule.workspaceAdmin": "工作区管理者",
"accessRule.workspaceOwner": "工作区所有者",
"common.duplicateAction": "创建副本",
"group.agent": "Agent",
diff --git a/web/i18n/locales/zh-Hant/permission.json b/web/i18n/locales/zh-Hant/permission.json
index ff51213c763..f983708357b 100644
--- a/web/i18n/locales/zh-Hant/permission.json
+++ b/web/i18n/locales/zh-Hant/permission.json
@@ -34,6 +34,7 @@
"accessRule.summary_one": "{{count}} 個權限集",
"accessRule.summary_other": "{{count}} 個權限集",
"accessRule.updated": "訪問規則已更新",
+ "accessRule.workspaceAdmin": "工作空間管理者",
"accessRule.workspaceOwner": "工作空間擁有者",
"common.duplicateAction": "建立副本",
"group.agent": "Agent",
diff --git a/web/i18n/resources.generated.d.ts b/web/i18n/resources.generated.d.ts
index 543baabf210..21b9629781a 100644
--- a/web/i18n/resources.generated.d.ts
+++ b/web/i18n/resources.generated.d.ts
@@ -3606,6 +3606,7 @@ export default interface Resources {
'accessRule.selected': 'Selected'
'accessRule.summary': '{{count}} permission set' | '{{count}} permission sets'
'accessRule.updated': 'Access rule updated successfully'
+ 'accessRule.workspaceAdmin': 'Workspace Admin'
'accessRule.workspaceOwner': 'Workspace Owner'
'common.duplicateAction': 'Duplicate'
'group.agent': 'Agents'
diff --git a/web/models/access-control.ts b/web/models/access-control.ts
index 346c351b97d..81f1a06246e 100644
--- a/web/models/access-control.ts
+++ b/web/models/access-control.ts
@@ -76,7 +76,7 @@ export type Role = {
description: string
is_builtin: boolean
permission_keys: PermissionKey[]
- role_tag: 'owner' | '' // Used for identifying the unique owner role, which has some special handlings
+ role_tag: 'owner' | 'admin' | '' // Identifies built-in workspace roles with special handling
}
type Pagination = {
@@ -144,7 +144,7 @@ type Bindings = {
role_name: string
binding_id: string
is_locked: boolean
- role_tag: 'owner' | '' // Used for identifying the unique owner role, which has some special handlings
+ role_tag: 'owner' | 'admin' | '' // Identifies built-in workspace roles with special handling
}>
accounts: Array<{
account_id: string
diff --git a/web/service/access-control/__tests__/normalizers.spec.ts b/web/service/access-control/__tests__/normalizers.spec.ts
index 647a2a061a4..d1f70f0c63d 100644
--- a/web/service/access-control/__tests__/normalizers.spec.ts
+++ b/web/service/access-control/__tests__/normalizers.spec.ts
@@ -58,5 +58,35 @@ describe('access-control normalizers', () => {
expect(normalize(response).data[0]?.roles[0]?.role_tag).toBe('owner')
})
+
+ it.each([
+ ['app', normalizeAppUserAccessPolicies],
+ ['dataset', normalizeDatasetUserAccessPolicies],
+ ] as const)('should preserve the workspace admin role tag for %s access', (_, normalize) => {
+ const response = createResourceUserAccessPoliciesResponse({
+ data: [
+ {
+ account: {
+ account_id: 'admin-account',
+ account_name: 'Workspace Admin',
+ },
+ roles: [
+ {
+ id: 'admin-role',
+ type: 'workspace',
+ category: 'global_system_default',
+ name: 'Admin',
+ is_builtin: true,
+ permission_keys: [],
+ role_tag: 'admin',
+ },
+ ],
+ access_policies: [],
+ },
+ ],
+ })
+
+ expect(normalize(response).data[0]?.roles[0]?.role_tag).toBe('admin')
+ })
})
})
diff --git a/web/service/access-control/normalizers.ts b/web/service/access-control/normalizers.ts
index 6d3c9eb67ac..37b6fae8316 100644
--- a/web/service/access-control/normalizers.ts
+++ b/web/service/access-control/normalizers.ts
@@ -43,7 +43,7 @@ const normalizeRoleType = (type?: string): Role['type'] => {
}
const normalizeRoleTag = (roleTag?: string): Role['role_tag'] => {
- if (roleTag === 'owner') return 'owner'
+ if (roleTag === 'owner' || roleTag === 'admin') return roleTag
return ''
}