From b9500113e6ce449e890cd9f3abbfed2359ef82a5 Mon Sep 17 00:00:00 2001 From: Alexandr Kuzmitsky Date: Thu, 19 Dec 2024 11:26:47 +0100 Subject: [PATCH] Add a feature toggle to allow users with VIEWER role to be oncalls --- engine/apps/api/permissions.py | 8 +++++++- engine/settings/base.py | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/engine/apps/api/permissions.py b/engine/apps/api/permissions.py index f37d72e9f..2d83b63bf 100644 --- a/engine/apps/api/permissions.py +++ b/engine/apps/api/permissions.py @@ -261,7 +261,13 @@ class Permissions: ) NOTIFICATIONS_READ = LegacyAccessControlCompatiblePermission( - Resources.NOTIFICATIONS, Actions.READ, LegacyAccessControlRole.EDITOR + Resources.NOTIFICATIONS, + Actions.READ, + ( + LegacyAccessControlRole.VIEWER + if settings.FEATURE_ALLOW_VIEWERS_ON_CALL + else LegacyAccessControlRole.EDITOR + ), ) NOTIFICATION_SETTINGS_READ = LegacyAccessControlCompatiblePermission( diff --git a/engine/settings/base.py b/engine/settings/base.py index 007779f19..769f66cde 100644 --- a/engine/settings/base.py +++ b/engine/settings/base.py @@ -76,6 +76,8 @@ FEATURE_ALERT_GROUP_SEARCH_CUTOFF_DAYS = getenv_integer("FEATURE_ALERT_GROUP_SEARCH_CUTOFF_DAYS", default=None) FEATURE_NOTIFICATION_BUNDLE_ENABLED = getenv_boolean("FEATURE_NOTIFICATION_BUNDLE_ENABLED", default=True) FEATURE_DECLARE_INCIDENT_STEP_ENABLED = getenv_boolean("FEATURE_DECLARE_INCIDENT_STEP_ENABLED", default=False) +# Allow users with legacy role VIEWER to be on call +FEATURE_ALLOW_VIEWERS_ON_CALL = getenv_boolean("FEATURE_ALLOW_VIEWERS_ON_CALL", default=False) TWILIO_API_KEY_SID = os.environ.get("TWILIO_API_KEY_SID") TWILIO_API_KEY_SECRET = os.environ.get("TWILIO_API_KEY_SECRET")