From 5be51de1eae16cc4f2ae6d234c5ea2fb14812f94 Mon Sep 17 00:00:00 2001 From: Innokentii Konstantinov Date: Wed, 8 Jun 2022 18:14:50 +0400 Subject: [PATCH 1/2] Sync only admins and editors --- engine/apps/api/views/features.py | 1 + 1 file changed, 1 insertion(+) diff --git a/engine/apps/api/views/features.py b/engine/apps/api/views/features.py index 81d0825a..4f106a89 100644 --- a/engine/apps/api/views/features.py +++ b/engine/apps/api/views/features.py @@ -49,6 +49,7 @@ class FeaturesAPIView(APIView): enabled_features.append(MOBILE_APP_PUSH_NOTIFICATIONS) if settings.OSS: + # Features below should be enabled only in OSS enabled_features.append(FEATURE_GRAFANA_CLOUD_CONNECTION) if settings.FEATURE_LIVE_SETTINGS_ENABLED: enabled_features.append(FEATURE_LIVE_SETTINGS) From af06d6491b7b0c34da9d46463c38605d03d8aae0 Mon Sep 17 00:00:00 2001 From: Innokentii Konstantinov Date: Wed, 8 Jun 2022 18:25:58 +0400 Subject: [PATCH 2/2] Add info throttler --- engine/apps/public_api/throttlers/__init__.py | 3 +++ engine/apps/public_api/throttlers/info_throttler.py | 6 ++++++ engine/apps/public_api/views/info.py | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 engine/apps/public_api/throttlers/info_throttler.py diff --git a/engine/apps/public_api/throttlers/__init__.py b/engine/apps/public_api/throttlers/__init__.py index e69de29b..20dc00d7 100644 --- a/engine/apps/public_api/throttlers/__init__.py +++ b/engine/apps/public_api/throttlers/__init__.py @@ -0,0 +1,3 @@ +from .info_throttler import InfoThrottler # noqa: F401 +from .phone_notification_throttler import PhoneNotificationThrottler # noqa: F401 +from .user_throttle import UserThrottle # noqa: F401 diff --git a/engine/apps/public_api/throttlers/info_throttler.py b/engine/apps/public_api/throttlers/info_throttler.py new file mode 100644 index 00000000..a48bce22 --- /dev/null +++ b/engine/apps/public_api/throttlers/info_throttler.py @@ -0,0 +1,6 @@ +from rest_framework.throttling import UserRateThrottle + + +class InfoThrottler(UserRateThrottle): + scope = "info" + rate = "100/m" diff --git a/engine/apps/public_api/views/info.py b/engine/apps/public_api/views/info.py index f9649181..f9cc13ca 100644 --- a/engine/apps/public_api/views/info.py +++ b/engine/apps/public_api/views/info.py @@ -3,14 +3,14 @@ from rest_framework.response import Response from rest_framework.views import APIView from apps.auth_token.auth import ApiTokenAuthentication -from apps.public_api.throttlers.user_throttle import UserThrottle +from apps.public_api.throttlers import InfoThrottler class InfoView(APIView): authentication_classes = (ApiTokenAuthentication,) permission_classes = (IsAuthenticated,) - throttle_classes = [UserThrottle] + throttle_classes = [InfoThrottler] def get(self, request): response = {"url": self.request.auth.organization.grafana_url}