From f61af74411ede5001891c8d0a4746aa6438f63d2 Mon Sep 17 00:00:00 2001 From: Yulya Artyukhina Date: Tue, 11 Apr 2023 18:36:46 +0200 Subject: [PATCH] Add mobile app auth for `notification_policies` endpoint (#1725) Add mobile app authentication for `notification_policies` endpoint --- README.md | 4 ++++ dev/README.md | 4 ++-- engine/apps/api/views/user_notification_policy.py | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index de308f87..586a348c 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ Developer-friendly incident response with brilliant Slack integration. + + @@ -20,6 +22,8 @@ Developer-friendly incident response with brilliant Slack integration.
+ + - Collect and analyze alerts from multiple monitoring systems - On-call rotations based on schedules - Automatic escalations diff --git a/dev/README.md b/dev/README.md index a79b4e6e..4f5495b2 100644 --- a/dev/README.md +++ b/dev/README.md @@ -40,8 +40,8 @@ environment variable. out/disable which components are run in Docker. 3. Open Grafana in a browser [here](http://localhost:3000/plugins/grafana-oncall-app) (login: `oncall`, password: `oncall`). 4. You should now see the OnCall plugin configuration page. You may safely ignore the warning about the invalid - plugin signature. Set "OnCall backend URL" as "http://host.docker.internal:8080". When opening the main plugin page, you may also ignore warnings about version mismatch and lack of - communication channels. + plugin signature. Set "OnCall backend URL" as "http://host.docker.internal:8080". When opening the main plugin page, + you may also ignore warnings about version mismatch and lack of communication channels. 5. Enjoy! Check our [OSS docs](https://grafana.com/docs/grafana-cloud/oncall/open-source/) if you want to set up Slack, Telegram, Twilio or SMS/calls through Grafana Cloud. 6. (Optional) Install `pre-commit` hooks by running `make install-precommit-hook` diff --git a/engine/apps/api/views/user_notification_policy.py b/engine/apps/api/views/user_notification_policy.py index 08b45c01..eb168b27 100644 --- a/engine/apps/api/views/user_notification_policy.py +++ b/engine/apps/api/views/user_notification_policy.py @@ -15,6 +15,7 @@ from apps.auth_token.auth import PluginAuthentication from apps.base.messaging import get_messaging_backend_from_id from apps.base.models import UserNotificationPolicy from apps.base.models.user_notification_policy import BUILT_IN_BACKENDS, NotificationChannelAPIOptions +from apps.mobile_app.auth import MobileAppAuthTokenAuthentication from apps.user_management.models import User from common.api_helpers.exceptions import BadRequest from common.api_helpers.mixins import UpdateSerializerMixin @@ -23,7 +24,10 @@ from common.insight_log import EntityEvent, write_resource_insight_log class UserNotificationPolicyView(UpdateSerializerMixin, ModelViewSet): - authentication_classes = (PluginAuthentication,) + authentication_classes = ( + MobileAppAuthTokenAuthentication, + PluginAuthentication, + ) permission_classes = (IsAuthenticated, RBACPermission) rbac_permissions = {