Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: update permission checks for non-IAM mode (#10431)

boojackd0c8c906e653
diff --git a/frontend/src/utils/iam/permission.ts b/frontend/src/utils/iam/permission.ts
index e09981baaa..46d43b8c44 100644
--- a/frontend/src/utils/iam/permission.ts
+++ b/frontend/src/utils/iam/permission.ts
@@ -1,6 +1,11 @@
-import { useProjectV1ListByUser, useRoleStore } from "@/store";
+import {
+ useActuatorV1Store,
+ useProjectV1ListByUser,
+ useRoleStore,
+} from "@/store";
import {
ComposedProject,
+ PresetRoleType,
ProjectPermission,
WorkspacePermission,
} from "@/types";
@@ -24,13 +29,27 @@ export const hasProjectPermissionV2 = (
permission: ProjectPermission
): boolean => {
const roleStore = useRoleStore();
+ const actuatorStore = useActuatorV1Store();
+ const isDevelopmentIAM = actuatorStore.serverInfo?.iamGuard;
+
// Check workspace-level permissions first.
- // For those users who have workspace-level project roles, they should have all project-level permissions.
- const workspaceLevelPermissions = user.roles
- .map((role) => roleStore.getRoleByName(role))
- .flatMap((role) => (role ? role.permissions : []));
- if (workspaceLevelPermissions.includes(permission)) {
- return true;
+ if (isDevelopmentIAM) {
+ // For those users who have workspace-level project roles, they should have all project-level permissions.
+ const workspaceLevelPermissions = user.roles
+ .map((role) => roleStore.getRoleByName(role))
+ .flatMap((role) => (role ? role.permissions : []));
+ if (workspaceLevelPermissions.includes(permission)) {
+ return true;
+ }
+ } else {
+ // TODO(steven): Remove this block after fine-grained permissions are supported.
+ const privilegedRoles = [
+ PresetRoleType.WORKSPACE_ADMIN,
+ PresetRoleType.WORKSPACE_DBA,
+ ];
+ if (user.roles.some((role) => privilegedRoles.includes(role))) {
+ return true;
+ }
}
// Check project-level permissions.