Skip to content

Commit

Permalink
chore: add rbac feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
VikaCep committed Dec 6, 2024
1 parent 274c3dc commit 3d529ee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/data/permissions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { OrgRole } from '@grafana/data';
import { config } from '@grafana/runtime';

import { PluginPermissions } from 'types';
import { FeatureName, PluginPermissions } from 'types';
import { isFeatureEnabled } from 'contexts/FeatureFlagContext';

const roleHierarchy: Record<OrgRole, OrgRole[]> = {
[OrgRole.Viewer]: [OrgRole.Viewer, OrgRole.Editor, OrgRole.Admin],
Expand All @@ -23,7 +24,8 @@ const hasMinFallbackRole = (fallbackOrgRole: OrgRole) => {
const isUserActionAllowed = (permission: PluginPermissions, fallbackOrgRole: OrgRole): boolean => {
const { permissions: userPermissions } = config.bootData.user;

if (config.featureToggles.accessControlOnCall) {
const rbacEnabled = isFeatureEnabled(FeatureName.RBAC);
if (config.featureToggles.accessControlOnCall && rbacEnabled) {
return Boolean(userPermissions?.[permission]);
}

Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ export enum FeatureName {
ScriptedChecks = 'scripted-checks',
UnifiedAlerting = 'ngalert',
UptimeQueryV2 = 'uptime-query-v2',
RBAC = 'synthetic-monitoring-rbac',
__TURNOFF = 'test-only-do-not-use',
}

Expand Down

0 comments on commit 3d529ee

Please sign in to comment.