Enable RLS in lab (#17328)
This commit is contained in:
+2
@@ -1,3 +1,5 @@
|
||||
/* @license Enterprise */
|
||||
|
||||
import { type ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { convertPredicateToRecordFilter } from '@/settings/roles/role-permissions/object-level-permissions/record-level-permissions/utils/recordLevelPermissionPredicateConversion';
|
||||
|
||||
|
||||
+9
@@ -37,6 +37,15 @@ export const PUBLIC_FEATURE_FLAGS: PublicFeatureFlag[] = [
|
||||
imagePath: 'https://twenty.com/images/lab/is-if-else-enabled.png',
|
||||
},
|
||||
},
|
||||
{
|
||||
key: FeatureFlagKey.IS_ROW_LEVEL_PERMISSION_PREDICATES_ENABLED,
|
||||
metadata: {
|
||||
label: 'Row Level Permissions',
|
||||
description: 'Enable row level permission',
|
||||
imagePath:
|
||||
'https://twenty.com/images/lab/is-row-level-permission-predicates-enabled.png',
|
||||
},
|
||||
},
|
||||
...(process.env.CLOUDFLARE_API_KEY
|
||||
? [
|
||||
// {
|
||||
|
||||
+9
@@ -12,6 +12,7 @@ import { type WorkspaceInternalContext } from 'src/engine/twenty-orm/interfaces/
|
||||
|
||||
import { DatabaseEventAction } from 'src/engine/api/graphql/graphql-query-runner/enums/database-event-action';
|
||||
import { type AuthContext } from 'src/engine/core-modules/auth/types/auth-context.type';
|
||||
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
|
||||
import { type QueryDeepPartialEntityWithNestedRelationFields } from 'src/engine/twenty-orm/entity-manager/types/query-deep-partial-entity-with-nested-relation-fields.type';
|
||||
import { type RelationConnectQueryConfig } from 'src/engine/twenty-orm/entity-manager/types/relation-connect-query-config.type';
|
||||
import { type RelationDisconnectQueryFieldsByEntityIndex } from 'src/engine/twenty-orm/entity-manager/types/relation-nested-query-fields-by-entity-index.type';
|
||||
@@ -273,6 +274,14 @@ export class WorkspaceInsertQueryBuilder<
|
||||
}
|
||||
|
||||
private validateRLSPredicatesForInsert(): void {
|
||||
if (
|
||||
this.featureFlagMap[
|
||||
FeatureFlagKey.IS_ROW_LEVEL_PERMISSION_PREDICATES_ENABLED
|
||||
] !== true
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const mainAliasTarget = this.getMainAliasTarget();
|
||||
const objectMetadata = getObjectMetadataFromEntityTarget(
|
||||
mainAliasTarget,
|
||||
|
||||
+9
@@ -10,6 +10,7 @@ import { type FeatureFlagMap } from 'src/engine/core-modules/feature-flag/interf
|
||||
import { type WorkspaceInternalContext } from 'src/engine/twenty-orm/interfaces/workspace-internal-context.interface';
|
||||
|
||||
import { type AuthContext } from 'src/engine/core-modules/auth/types/auth-context.type';
|
||||
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
|
||||
import {
|
||||
PermissionsException,
|
||||
PermissionsExceptionCode,
|
||||
@@ -357,6 +358,14 @@ export class WorkspaceSelectQueryBuilder<
|
||||
}
|
||||
|
||||
private applyRowLevelPermissionPredicates(): void {
|
||||
if (
|
||||
this.featureFlagMap[
|
||||
FeatureFlagKey.IS_ROW_LEVEL_PERMISSION_PREDICATES_ENABLED
|
||||
] !== true
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.shouldBypassPermissionChecks) {
|
||||
return;
|
||||
}
|
||||
|
||||
+17
@@ -16,6 +16,7 @@ import { type WorkspaceInternalContext } from 'src/engine/twenty-orm/interfaces/
|
||||
|
||||
import { DatabaseEventAction } from 'src/engine/api/graphql/graphql-query-runner/enums/database-event-action';
|
||||
import { type AuthContext } from 'src/engine/core-modules/auth/types/auth-context.type';
|
||||
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
|
||||
import { type QueryDeepPartialEntityWithNestedRelationFields } from 'src/engine/twenty-orm/entity-manager/types/query-deep-partial-entity-with-nested-relation-fields.type';
|
||||
import { type RelationConnectQueryConfig } from 'src/engine/twenty-orm/entity-manager/types/relation-connect-query-config.type';
|
||||
import { type RelationDisconnectQueryFieldsByEntityIndex } from 'src/engine/twenty-orm/entity-manager/types/relation-nested-query-fields-by-entity-index.type';
|
||||
@@ -540,6 +541,14 @@ export class WorkspaceUpdateQueryBuilder<
|
||||
}
|
||||
|
||||
private applyRowLevelPermissionPredicates(): void {
|
||||
if (
|
||||
this.featureFlagMap[
|
||||
FeatureFlagKey.IS_ROW_LEVEL_PERMISSION_PREDICATES_ENABLED
|
||||
] !== true
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.shouldBypassPermissionChecks) {
|
||||
return;
|
||||
}
|
||||
@@ -565,6 +574,14 @@ export class WorkspaceUpdateQueryBuilder<
|
||||
}: {
|
||||
updatedRecords: T[];
|
||||
}): void {
|
||||
if (
|
||||
this.featureFlagMap[
|
||||
FeatureFlagKey.IS_ROW_LEVEL_PERMISSION_PREDICATES_ENABLED
|
||||
] !== true
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const mainAliasTarget = this.getMainAliasTarget();
|
||||
const objectMetadata = getObjectMetadataFromEntityTarget(
|
||||
mainAliasTarget,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/* @license Enterprise */
|
||||
|
||||
import { type RowLevelPermissionPredicateOperand } from '@/types/RowLevelPermissionPredicateOperand';
|
||||
import { type RowLevelPermissionPredicateValue } from '@/types/RowLevelPermissionPredicateValue';
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/* @license Enterprise */
|
||||
|
||||
import { type RowLevelPermissionPredicateGroupLogicalOperator } from '@/types/RowLevelPermissionPredicateGroupLogicalOperator';
|
||||
|
||||
export type RowLevelPermissionPredicateGroup = {
|
||||
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 332 KiB |
Reference in New Issue
Block a user