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: protect workspace owners in resource access (#41423)

Wu Tianwei1971450ad808
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 82a516c7b32..d13d09a3332 100644
--- a/web/app/components/access-rules-editor/__tests__/index.spec.tsx
+++ b/web/app/components/access-rules-editor/__tests__/index.spec.tsx
@@ -32,7 +32,9 @@ const createRule = (resourceType: 'app' | 'dataset'): AccessPolicyWithBindings =
accounts: [],
})
-const createUserAccessSetting = (): ResourceUserAccessSetting => ({
+const createUserAccessSetting = (
+ resourceType: 'app' | 'dataset' = 'app',
+): ResourceUserAccessSetting => ({
account: {
account_id: 'account-1',
account_name: 'Evan',
@@ -46,14 +48,15 @@ const createUserAccessSetting = (): ResourceUserAccessSetting => ({
name: 'Maintainer',
is_builtin: false,
permission_keys: [],
+ role_tag: '',
},
],
access_policies: [
{
- id: 'app-policy-id',
+ id: `${resourceType}-policy-id`,
tenant_id: 'tenant-id',
- resource_type: 'app',
- policy_key: 'app-policy-key',
+ resource_type: resourceType,
+ policy_key: `${resourceType}-policy-key`,
name: 'Manage',
description: 'Can manage this app',
permission_keys: [],
@@ -267,6 +270,113 @@ describe('AccessRulesEditor', () => {
expect(onRemoveAccessPolicyMemberBinding).not.toHaveBeenCalled()
})
+ it.each(['app', 'dataset'] as const)(
+ 'should prevent editing or removing the workspace owner from %s access',
+ async (resourceType) => {
+ const user = userEvent.setup()
+ mockMembers.accounts = [
+ createMember({
+ id: 'workspace-owner',
+ name: 'Workspace Owner',
+ email: '[email protected]',
+ }),
+ createMember(),
+ ]
+ const ownerSetting: ResourceUserAccessSetting = {
+ ...createUserAccessSetting(resourceType),
+ account: {
+ account_id: 'workspace-owner',
+ account_name: 'Workspace Owner',
+ email: '[email protected]',
+ },
+ roles: [
+ {
+ id: 'owner-role',
+ type: 'workspace',
+ category: 'global_system_default',
+ name: 'Owner',
+ is_builtin: true,
+ permission_keys: [],
+ role_tag: 'owner',
+ },
+ ],
+ }
+ 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)
+ const onAddAccessSubject = vi.fn()
+
+ render(
+ <AccessRulesEditor
+ rules={[createRule(resourceType)]}
+ userAccessSettings={[ownerSetting, memberSetting]}
+ isLoadingRules={false}
+ isLoadingUserAccessSettings={false}
+ automaticIncludeWorkspaceMembers={false}
+ isUpdatingAutomaticIncludeWorkspaceMembers={false}
+ existingAccountIds={[]}
+ updatingAccountId={null}
+ onUserAccessPoliciesChange={onUserAccessPoliciesChange}
+ onRemoveAccessPolicyMemberBinding={onRemoveAccessPolicyMemberBinding}
+ onBatchRemoveAccessPolicyMemberBindings={onBatchRemoveAccessPolicyMemberBindings}
+ onAddAccessSubject={onAddAccessSubject}
+ />,
+ )
+
+ const ownerRow = screen.getByRole('row', { name: /Workspace Owner/ })
+ expect(within(ownerRow).getByText('permission.accessRule.workspaceOwner')).toBeInTheDocument()
+ expect(within(ownerRow).getByRole('checkbox', { name: 'Workspace Owner' })).toHaveAttribute(
+ 'aria-disabled',
+ 'true',
+ )
+ expect(
+ within(ownerRow).getByLabelText(/permission\.accessRule\.exceptionPermissionFor/),
+ ).toBeDisabled()
+ expect(
+ within(ownerRow).getByRole('button', { name: 'common.operation.remove' }),
+ ).toBeDisabled()
+
+ await user.click(screen.getByRole('checkbox', { name: 'common.operation.selectAll' }))
+ expect(screen.getByRole('checkbox', { name: 'Workspace Owner' })).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()
+
+ await user.click(screen.getByRole('button', { name: 'common.operation.add' }))
+ const addDialog = await screen.findByRole('dialog', {
+ name: 'permission.accessRule.addMembersTitle',
+ })
+ expect(within(addDialog).getByText('Workspace Owner')).toBeInTheDocument()
+ expect(
+ within(addDialog).getByRole('button', { name: 'common.operation.added' }),
+ ).toBeDisabled()
+ expect(
+ within(addDialog).queryByRole('button', {
+ name: 'permission.accessRule.addMemberAria:{"name":"Workspace Owner"}',
+ }),
+ ).not.toBeInTheDocument()
+ expect(onAddAccessSubject).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/constants.ts b/web/app/components/access-rules-editor/constants.ts
index 25eb9dd549f..9aea21538fa 100644
--- a/web/app/components/access-rules-editor/constants.ts
+++ b/web/app/components/access-rules-editor/constants.ts
@@ -1,3 +1,3 @@
export const ACCESS_RULE_TABLE_GRID =
- 'grid-cols-[minmax(0,0.72fr)_minmax(0,1fr)_minmax(72px,0.54fr)]'
+ 'grid-cols-[minmax(0,1fr)_minmax(0,0.75fr)_minmax(72px,0.45fr)]'
export const DEFAULT_ACCESS_POLICY_ID = 'default'
diff --git a/web/app/components/access-rules-editor/index.tsx b/web/app/components/access-rules-editor/index.tsx
index 1f1a185e683..39a72eb2d15 100644
--- a/web/app/components/access-rules-editor/index.tsx
+++ b/web/app/components/access-rules-editor/index.tsx
@@ -82,12 +82,28 @@ function AccessRulesEditor({
name: rule.policy.name,
}))
}, [rules])
+ const protectedAccountIds = useMemo(() => {
+ const accountIds = new Set<string>()
+
+ 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)
+ }
+
+ return accountIds
+ }, [maintainerId, userAccessSettings])
+ const existingOrProtectedAccountIds = useMemo(() => {
+ if (existingAccountIds === undefined) return undefined
+
+ return Array.from(new Set([...existingAccountIds, ...protectedAccountIds]))
+ }, [existingAccountIds, protectedAccountIds])
const selectableAccountIds = useMemo(
() =>
userAccessSettings
.map((setting) => setting.account.account_id)
- .filter((accountId) => accountId !== maintainerId),
- [maintainerId, userAccessSettings],
+ .filter((accountId) => !protectedAccountIds.has(accountId)),
+ [protectedAccountIds, userAccessSettings],
)
const selectedAccountCount = selectableAccountIds.filter((accountId) =>
selectedAccountIds.has(accountId),
@@ -101,7 +117,7 @@ function AccessRulesEditor({
for (const setting of userAccessSettings) {
const accountId = setting.account.account_id
- if (!selectedAccountIds.has(accountId) || accountId === maintainerId) continue
+ if (!selectedAccountIds.has(accountId) || protectedAccountIds.has(accountId)) continue
const accessPolicyId = setting.access_policies[0]?.id ?? DEFAULT_ACCESS_POLICY_ID
const accountIds = accountIdsByAccessPolicyId.get(accessPolicyId)
@@ -113,7 +129,7 @@ function AccessRulesEditor({
accessPolicyId,
accountIds,
}))
- }, [maintainerId, selectedAccountIds, userAccessSettings])
+ }, [protectedAccountIds, selectedAccountIds, userAccessSettings])
const handleSelectAllAccounts = useCallback(
(selected: boolean) => {
@@ -205,7 +221,7 @@ function AccessRulesEditor({
{onAddAccessSubject ? (
<AddAccessSubjectPopover
disabled={areMembershipChangesDisabled}
- existingAccountIds={existingAccountIds}
+ existingAccountIds={existingOrProtectedAccountIds}
updatingAccountId={updatingAccountId}
onAddAccessSubject={onAddAccessSubject}
/>
@@ -299,8 +315,12 @@ function AccessRulesEditor({
disabled={isChangingPage || updatingAccountId === setting.account.account_id}
membershipChangesDisabled={areMembershipChangesDisabled}
selectionDisabled={!onBatchRemoveAccessPolicyMemberBindings}
+ isProtected={protectedAccountIds.has(setting.account.account_id)}
isMaintainer={maintainerId === setting.account.account_id}
- selected={selectedAccountIds.has(setting.account.account_id)}
+ selected={
+ !protectedAccountIds.has(setting.account.account_id) &&
+ selectedAccountIds.has(setting.account.account_id)
+ }
className={cn(index > 0 && 'border-t border-divider-subtle')}
onSelectedChange={handleAccountSelectedChange}
onChange={onUserAccessPoliciesChange}
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 b1a1a22e1e5..75b2ee7c70b 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
@@ -28,6 +28,7 @@ type UserAccessPolicyRowProps = {
disabled: boolean
membershipChangesDisabled?: boolean
selectionDisabled?: boolean
+ isProtected?: boolean
isMaintainer?: boolean
selected?: boolean
className?: string
@@ -42,6 +43,7 @@ function UserAccessPolicyRow({
disabled,
membershipChangesDisabled = false,
selectionDisabled = false,
+ isProtected = false,
isMaintainer = false,
selected = false,
className,
@@ -53,12 +55,13 @@ function UserAccessPolicyRow({
const accountId = setting.account.account_id
const selectedPolicy = setting.access_policies[0]
const selectedPolicyId = selectedPolicy?.id ?? DEFAULT_ACCESS_POLICY_ID
- const isPolicySelectDisabled = disabled || isMaintainer || !onChange
- const isRemoveDisabled = disabled || membershipChangesDisabled || isMaintainer || !onRemove
+ const isPolicySelectDisabled = disabled || isProtected || !onChange
+ const isRemoveDisabled = disabled || membershipChangesDisabled || isProtected || !onRemove
const isSelectionDisabled =
- disabled || membershipChangesDisabled || selectionDisabled || isMaintainer || !onSelectedChange
+ disabled || membershipChangesDisabled || selectionDisabled || isProtected || !onSelectedChange
const defaultAccessPolicyName = t(($) => $['accessRule.defaultPermission'], { ns: 'permission' })
const accountEmail = setting.account.email || setting.account.account_name
+ const isWorkspaceOwner = setting.roles.some((role) => role.role_tag === 'owner')
const handlePolicyChange = useCallback(
(nextPolicyId: string | null) => {
@@ -96,10 +99,15 @@ function UserAccessPolicyRow({
{setting.account.account_name}
</span>
{isMaintainer && (
- <span className="max-w-24 shrink-0 truncate rounded-[5px] border border-text-accent-secondary px-1 py-0.5 system-2xs-medium-uppercase text-text-accent-secondary">
+ <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.maintainer'], { ns: 'permission' })}
</span>
)}
+ {isWorkspaceOwner && (
+ <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.workspaceOwner'], { ns: 'permission' })}
+ </span>
+ )}
</div>
<p className="truncate system-xs-regular text-text-tertiary">{accountEmail}</p>
</div>
@@ -113,7 +121,7 @@ function UserAccessPolicyRow({
})}
size="small"
disabled={isPolicySelectDisabled}
- className="w-30.25"
+ className="w-full max-w-50"
>
<SelectValue>
{selectedPolicyId === DEFAULT_ACCESS_POLICY_ID
diff --git a/web/i18n/ar-TN/permission.json b/web/i18n/ar-TN/permission.json
index 1a0bdc89b3f..4aec61eaeb3 100644
--- a/web/i18n/ar-TN/permission.json
+++ b/web/i18n/ar-TN/permission.json
@@ -42,6 +42,7 @@
"accessRule.summary_one": "{{count}} مجموعة أذونات",
"accessRule.summary_other": "{{count}} مجموعات أذونات",
"accessRule.updated": "تم تحديث قاعدة الوصول بنجاح",
+ "accessRule.workspaceOwner": "مالك مساحة العمل",
"common.duplicateAction": "تكرار",
"group.app": "التطبيقات",
"group.app_acl": "أذونات الوصول إلى التطبيق",
diff --git a/web/i18n/de-DE/permission.json b/web/i18n/de-DE/permission.json
index 53f573305e9..623d2edf533 100644
--- a/web/i18n/de-DE/permission.json
+++ b/web/i18n/de-DE/permission.json
@@ -42,6 +42,7 @@
"accessRule.summary_one": "{{count}} Berechtigungssatz",
"accessRule.summary_other": "{{count}} Berechtigungssätze",
"accessRule.updated": "Zugriffsregel erfolgreich aktualisiert",
+ "accessRule.workspaceOwner": "Workspace-Inhaber",
"common.duplicateAction": "Duplizieren",
"group.app": "Anwendungen",
"group.app_acl": "App-Zugriffsberechtigungen",
diff --git a/web/i18n/en-US/permission.json b/web/i18n/en-US/permission.json
index 48fa3c7443f..b683ef09acd 100644
--- a/web/i18n/en-US/permission.json
+++ b/web/i18n/en-US/permission.json
@@ -42,6 +42,7 @@
"accessRule.summary_one": "{{count}} permission set",
"accessRule.summary_other": "{{count}} permission sets",
"accessRule.updated": "Access rule updated successfully",
+ "accessRule.workspaceOwner": "Workspace Owner",
"common.duplicateAction": "Duplicate",
"group.app": "Applications",
"group.app_acl": "App access permissions",
diff --git a/web/i18n/es-ES/permission.json b/web/i18n/es-ES/permission.json
index 1f5b04f51f7..65e1aeb6303 100644
--- a/web/i18n/es-ES/permission.json
+++ b/web/i18n/es-ES/permission.json
@@ -42,6 +42,7 @@
"accessRule.summary_one": "{{count}} conjunto de permisos",
"accessRule.summary_other": "{{count}} conjuntos de permisos",
"accessRule.updated": "Regla de acceso actualizada correctamente",
+ "accessRule.workspaceOwner": "Propietario del espacio de trabajo",
"common.duplicateAction": "Duplicar",
"group.app": "Aplicaciones",
"group.app_acl": "Permisos de acceso de la app",
diff --git a/web/i18n/fa-IR/permission.json b/web/i18n/fa-IR/permission.json
index c281a23e036..16c582376ad 100644
--- a/web/i18n/fa-IR/permission.json
+++ b/web/i18n/fa-IR/permission.json
@@ -42,6 +42,7 @@
"accessRule.summary_one": "{{count}} مجموعه مجوز",
"accessRule.summary_other": "{{count}} مجموعه مجوز",
"accessRule.updated": "قانون دسترسی با موفقیت به‌روزرسانی شد",
+ "accessRule.workspaceOwner": "مالک فضای کاری",
"common.duplicateAction": "تکثیر",
"group.app": "برنامه‌ها",
"group.app_acl": "مجوزهای دسترسی برنامه",
diff --git a/web/i18n/fr-FR/permission.json b/web/i18n/fr-FR/permission.json
index 79bdd910672..835392f62bd 100644
--- a/web/i18n/fr-FR/permission.json
+++ b/web/i18n/fr-FR/permission.json
@@ -42,6 +42,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.workspaceOwner": "Propriétaire de l’espace de travail",
"common.duplicateAction": "Dupliquer",
"group.app": "Applications",
"group.app_acl": "Autorisations d'accès à l'application",
diff --git a/web/i18n/hi-IN/permission.json b/web/i18n/hi-IN/permission.json
index 023a3a91ced..f014a69af56 100644
--- a/web/i18n/hi-IN/permission.json
+++ b/web/i18n/hi-IN/permission.json
@@ -42,6 +42,7 @@
"accessRule.summary_one": "{{count}} अनुमति सेट",
"accessRule.summary_other": "{{count}} अनुमति सेट",
"accessRule.updated": "एक्सेस नियम सफलतापूर्वक अपडेट किया गया",
+ "accessRule.workspaceOwner": "वर्कस्पेस का मालिक",
"common.duplicateAction": "डुप्लिकेट करें",
"group.app": "अनुप्रयोग",
"group.app_acl": "ऐप एक्सेस अनुमतियाँ",
diff --git a/web/i18n/id-ID/permission.json b/web/i18n/id-ID/permission.json
index 18750d8be96..fb3024be75f 100644
--- a/web/i18n/id-ID/permission.json
+++ b/web/i18n/id-ID/permission.json
@@ -42,6 +42,7 @@
"accessRule.summary_one": "{{count}} set izin",
"accessRule.summary_other": "{{count}} set izin",
"accessRule.updated": "Aturan akses berhasil diperbarui",
+ "accessRule.workspaceOwner": "Pemilik Workspace",
"common.duplicateAction": "Duplikat",
"group.app": "Aplikasi",
"group.app_acl": "Izin akses aplikasi",
diff --git a/web/i18n/it-IT/permission.json b/web/i18n/it-IT/permission.json
index a10c3364d76..6b687d50016 100644
--- a/web/i18n/it-IT/permission.json
+++ b/web/i18n/it-IT/permission.json
@@ -42,6 +42,7 @@
"accessRule.summary_one": "{{count}} set di permessi",
"accessRule.summary_other": "{{count}} set di permessi",
"accessRule.updated": "Regola di accesso aggiornata con successo",
+ "accessRule.workspaceOwner": "Proprietario del workspace",
"common.duplicateAction": "Duplica",
"group.app": "Applicazioni",
"group.app_acl": "Permessi di accesso all'app",
diff --git a/web/i18n/ja-JP/permission.json b/web/i18n/ja-JP/permission.json
index 0dbd5e73369..7734c99af03 100644
--- a/web/i18n/ja-JP/permission.json
+++ b/web/i18n/ja-JP/permission.json
@@ -42,6 +42,7 @@
"accessRule.summary_one": "{{count}} 件の権限セット",
"accessRule.summary_other": "{{count}} 件の権限セット",
"accessRule.updated": "アクセスルールを更新しました",
+ "accessRule.workspaceOwner": "ワークスペースのオーナー",
"common.duplicateAction": "複製",
"group.app": "アプリ",
"group.app_acl": "アプリアクセス権限",
diff --git a/web/i18n/ko-KR/permission.json b/web/i18n/ko-KR/permission.json
index d01e8b55df9..94b55e8fdab 100644
--- a/web/i18n/ko-KR/permission.json
+++ b/web/i18n/ko-KR/permission.json
@@ -42,6 +42,7 @@
"accessRule.summary_one": "{{count}}개 권한 집합",
"accessRule.summary_other": "{{count}}개 권한 집합",
"accessRule.updated": "접근 규칙이 성공적으로 업데이트되었습니다",
+ "accessRule.workspaceOwner": "워크스페이스 소유자",
"common.duplicateAction": "복제",
"group.app": "애플리케이션",
"group.app_acl": "앱 접근 권한",
diff --git a/web/i18n/lo-LA/permission.json b/web/i18n/lo-LA/permission.json
index b5123abf8b9..69a3fa730d7 100644
--- a/web/i18n/lo-LA/permission.json
+++ b/web/i18n/lo-LA/permission.json
@@ -42,6 +42,7 @@
"accessRule.summary_one": "{{count}} ຊຸດສິດ",
"accessRule.summary_other": "{{count}} ຊຸດສິດ",
"accessRule.updated": "ອັບເດດກົດລະບຽບການເຂົ້າເຖິງສຳເລັດແລ້ວ",
+ "accessRule.workspaceOwner": "ເຈົ້າຂອງພື້ນທີ່ເຮັດວຽກ",
"common.duplicateAction": "ເຮັດສຳເນົາ",
"group.app": "ແອັບພລິເຄຊັນ",
"group.app_acl": "ສິດການເຂົ້າເຖິງແອັບຯ",
diff --git a/web/i18n/nl-NL/permission.json b/web/i18n/nl-NL/permission.json
index 0ff57357dbc..c49ef42aff7 100644
--- a/web/i18n/nl-NL/permission.json
+++ b/web/i18n/nl-NL/permission.json
@@ -42,6 +42,7 @@
"accessRule.summary_one": "{{count}} rechtenset",
"accessRule.summary_other": "{{count}} rechtensets",
"accessRule.updated": "Toegangsregel succesvol bijgewerkt",
+ "accessRule.workspaceOwner": "Eigenaar van de workspace",
"common.duplicateAction": "Dupliceren",
"group.app": "Applicaties",
"group.app_acl": "Toegangsrechten voor app",
diff --git a/web/i18n/pl-PL/permission.json b/web/i18n/pl-PL/permission.json
index 22a3bd77153..54c0e88e272 100644
--- a/web/i18n/pl-PL/permission.json
+++ b/web/i18n/pl-PL/permission.json
@@ -42,6 +42,7 @@
"accessRule.summary_one": "{{count}} zestaw uprawnień",
"accessRule.summary_other": "{{count}} zestawów uprawnień",
"accessRule.updated": "Pomyślnie zaktualizowano regułę dostępu",
+ "accessRule.workspaceOwner": "Właściciel obszaru roboczego",
"common.duplicateAction": "Duplikuj",
"group.app": "Aplikacje",
"group.app_acl": "Uprawnienia dostępu do aplikacji",
diff --git a/web/i18n/pt-BR/permission.json b/web/i18n/pt-BR/permission.json
index cdfd047b628..5037be2bddd 100644
--- a/web/i18n/pt-BR/permission.json
+++ b/web/i18n/pt-BR/permission.json
@@ -42,6 +42,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.workspaceOwner": "Proprietário do workspace",
"common.duplicateAction": "Duplicar",
"group.app": "Aplicativos",
"group.app_acl": "Permissões de acesso ao aplicativo",
diff --git a/web/i18n/ro-RO/permission.json b/web/i18n/ro-RO/permission.json
index 73c26ba997b..f3a01f1110f 100644
--- a/web/i18n/ro-RO/permission.json
+++ b/web/i18n/ro-RO/permission.json
@@ -42,6 +42,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.workspaceOwner": "Proprietarul spațiului de lucru",
"common.duplicateAction": "Duplică",
"group.app": "Aplicații",
"group.app_acl": "Permisiuni de acces ale aplicației",
diff --git a/web/i18n/ru-RU/permission.json b/web/i18n/ru-RU/permission.json
index 4f7216e19b6..b37eed36332 100644
--- a/web/i18n/ru-RU/permission.json
+++ b/web/i18n/ru-RU/permission.json
@@ -42,6 +42,7 @@
"accessRule.summary_one": "{{count}} набор прав",
"accessRule.summary_other": "{{count}} наборов прав",
"accessRule.updated": "Правило доступа успешно обновлено",
+ "accessRule.workspaceOwner": "Владелец рабочего пространства",
"common.duplicateAction": "Дублировать",
"group.app": "Приложения",
"group.app_acl": "Права доступа к приложению",
diff --git a/web/i18n/sl-SI/permission.json b/web/i18n/sl-SI/permission.json
index c2e5d268eaa..6dc5888a25e 100644
--- a/web/i18n/sl-SI/permission.json
+++ b/web/i18n/sl-SI/permission.json
@@ -42,6 +42,7 @@
"accessRule.summary_one": "{{count}} nabor dovoljenj",
"accessRule.summary_other": "{{count}} naborov dovoljenj",
"accessRule.updated": "Pravilo za dostop uspešno posodobljeno",
+ "accessRule.workspaceOwner": "Lastnik delovnega prostora",
"common.duplicateAction": "Podvoji",
"group.app": "Aplikacije",
"group.app_acl": "Dovoljenja za dostop do aplikacije",
diff --git a/web/i18n/th-TH/permission.json b/web/i18n/th-TH/permission.json
index 767c2f329d9..83b1dc56bb4 100644
--- a/web/i18n/th-TH/permission.json
+++ b/web/i18n/th-TH/permission.json
@@ -42,6 +42,7 @@
"accessRule.summary_one": "ชุดสิทธิ์ {{count}} ชุด",
"accessRule.summary_other": "ชุดสิทธิ์ {{count}} ชุด",
"accessRule.updated": "อัปเดตกฎการเข้าถึงสําเร็จ",
+ "accessRule.workspaceOwner": "เจ้าของเวิร์กสเปซ",
"common.duplicateAction": "ทําซ้ํา",
"group.app": "แอปพลิเคชัน",
"group.app_acl": "สิทธิ์การเข้าถึงแอป",
diff --git a/web/i18n/tr-TR/permission.json b/web/i18n/tr-TR/permission.json
index f164724b816..a9bf3e3a206 100644
--- a/web/i18n/tr-TR/permission.json
+++ b/web/i18n/tr-TR/permission.json
@@ -42,6 +42,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.workspaceOwner": "Çalışma alanı sahibi",
"common.duplicateAction": "Çoğalt",
"group.app": "Uygulamalar",
"group.app_acl": "Uygulama erişim izinleri",
diff --git a/web/i18n/uk-UA/permission.json b/web/i18n/uk-UA/permission.json
index cb128b8b822..10a7666a905 100644
--- a/web/i18n/uk-UA/permission.json
+++ b/web/i18n/uk-UA/permission.json
@@ -42,6 +42,7 @@
"accessRule.summary_one": "{{count}} набір дозволів",
"accessRule.summary_other": "{{count}} наборів дозволів",
"accessRule.updated": "Правило доступу успішно оновлено",
+ "accessRule.workspaceOwner": "Власник робочого простору",
"common.duplicateAction": "Дублювати",
"group.app": "Застосунки",
"group.app_acl": "Дозволи доступу до застосунку",
diff --git a/web/i18n/vi-VN/permission.json b/web/i18n/vi-VN/permission.json
index bb6555b1a05..5606220f305 100644
--- a/web/i18n/vi-VN/permission.json
+++ b/web/i18n/vi-VN/permission.json
@@ -42,6 +42,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.workspaceOwner": "Chủ sở hữu workspace",
"common.duplicateAction": "Nhân bản",
"group.app": "Ứng dụng",
"group.app_acl": "Quyền truy cập ứng dụng",
diff --git a/web/i18n/zh-Hans/permission.json b/web/i18n/zh-Hans/permission.json
index 41f9a51eea6..c6ca169c5ee 100644
--- a/web/i18n/zh-Hans/permission.json
+++ b/web/i18n/zh-Hans/permission.json
@@ -42,6 +42,7 @@
"accessRule.summary_one": "{{count}} 个权限集",
"accessRule.summary_other": "{{count}} 个权限集",
"accessRule.updated": "访问规则已更新",
+ "accessRule.workspaceOwner": "工作区所有者",
"common.duplicateAction": "创建副本",
"group.app": "应用",
"group.app_acl": "应用访问权限",
diff --git a/web/i18n/zh-Hant/permission.json b/web/i18n/zh-Hant/permission.json
index 217e7a108da..331be78cc75 100644
--- a/web/i18n/zh-Hant/permission.json
+++ b/web/i18n/zh-Hant/permission.json
@@ -42,6 +42,7 @@
"accessRule.summary_one": "{{count}} 個權限集",
"accessRule.summary_other": "{{count}} 個權限集",
"accessRule.updated": "訪問規則已更新",
+ "accessRule.workspaceOwner": "工作空間擁有者",
"common.duplicateAction": "建立副本",
"group.app": "應用",
"group.app_acl": "應用訪問權限",
diff --git a/web/models/access-control.ts b/web/models/access-control.ts
index e41869f4091..b32cb29ee7b 100644
--- a/web/models/access-control.ts
+++ b/web/models/access-control.ts
@@ -219,7 +219,7 @@ type Account = {
export type ResourceUserAccessSetting = {
account: Account
- roles: Omit<Role, 'tenant_id' | 'description' | 'role_tag'>[]
+ roles: Omit<Role, 'tenant_id' | 'description'>[]
access_policies: Omit<AccessPolicy, 'created_at' | 'updated_at'>[]
}
diff --git a/web/service/access-control/__tests__/normalizers.spec.ts b/web/service/access-control/__tests__/normalizers.spec.ts
index 624147fccaf..647a2a061a4 100644
--- a/web/service/access-control/__tests__/normalizers.spec.ts
+++ b/web/service/access-control/__tests__/normalizers.spec.ts
@@ -1,5 +1,5 @@
import type { ResourceUserAccessPoliciesResponse } from '@dify/contracts/api/console/workspaces/types.gen'
-import { normalizeAppUserAccessPolicies } from '../normalizers'
+import { normalizeAppUserAccessPolicies, normalizeDatasetUserAccessPolicies } from '../normalizers'
const createResourceUserAccessPoliciesResponse = (
overrides: Partial<ResourceUserAccessPoliciesResponse> = {},
@@ -28,5 +28,35 @@ describe('access-control normalizers', () => {
total_pages: 3,
})
})
+
+ it.each([
+ ['app', normalizeAppUserAccessPolicies],
+ ['dataset', normalizeDatasetUserAccessPolicies],
+ ] as const)('should preserve the workspace owner role tag for %s access', (_, normalize) => {
+ const response = createResourceUserAccessPoliciesResponse({
+ data: [
+ {
+ account: {
+ account_id: 'owner-account',
+ account_name: 'Workspace Owner',
+ },
+ roles: [
+ {
+ id: 'owner-role',
+ type: 'workspace',
+ category: 'global_system_default',
+ name: 'Owner',
+ is_builtin: true,
+ permission_keys: [],
+ role_tag: 'owner',
+ },
+ ],
+ access_policies: [],
+ },
+ ],
+ })
+
+ expect(normalize(response).data[0]?.roles[0]?.role_tag).toBe('owner')
+ })
})
})
diff --git a/web/service/access-control/normalizers.ts b/web/service/access-control/normalizers.ts
index b30b1eeaf42..6d3c9eb67ac 100644
--- a/web/service/access-control/normalizers.ts
+++ b/web/service/access-control/normalizers.ts
@@ -125,6 +125,7 @@ const normalizeRole = (role: GeneratedRbacRole): ResourceUserAccessSetting['role
name: role.name,
is_builtin: role.is_builtin ?? false,
permission_keys: role.permission_keys ?? [],
+ role_tag: normalizeRoleTag(role.role_tag),
})
const normalizeResourceUserAccessSetting = (