Commit graph

91 commits

Author SHA1 Message Date
Joey Orlando
9a7b8acd5a
centralize timezone validation + add serializer validation for on call shifts and schedules (#924)
* Centralize timezone validation into one spot + add serializer validation
for schedules and oncall shifts (both public and internal API)

* add engine-manage make command
2022-12-01 14:13:39 +01:00
Joey Orlando
9e598385f4
Add RBAC Support (#777)
* Modify plugin.json to support RBAC role registration

* defines 26 new custom roles in plugin.json. The main roles are:

- Admin: read/write access to everything in OnCall
- Reader: read access to everything in OnCall
- OnCaller : read access to everything in OnCall + edit access to Alert Groups and Schedules
- <object-type> Editor: read/write access to everything related to <object-type>
- <object-type> Reader: read access for <object-type>
- User Settings Admin: read/write access to all user's settings, not just own settings. This is in comparison to User Settings Editor which can only read/write own settings

* update changelog and documentation (#686)

* implement RBAC for OnCall backend

This commit refactors backend authorization. It trys to use RBAC authorization if the org's grafana instance supports it, otherwise it falls back to basic role authorization.

* update RBAC backend tests

* add tests for RBAC changes
- run backend tests as matrix where RBAC is enabled/disabled. When RBAC is enabled, the permissions granted are read from the role grants in the frontend's plugin.json file (instead of relying what we specify in RBACPermission.Permissions)
- remove --reuse-db --nomigrations flags from engine/tox.ini
- minor autoformatting changes to docker-compose-developer.yml

* remove --ds=settings.ci-test from pytest CI command

DJANGO_SETTINGS_MODULE is already specified as an env var so this is just unecessary duplication

* update gitignore

* update github action job name for "test"

* RBAC frontend changes

* refactors the use of basic roles (ex. Viewer, Editor, Admin) use RBAC permissions (when supported), or falling back to basic roles when RBAC is not supported.

- updates the UserAction enum in grafana-plugin/src/state/userAction.ts. Previously this was hardcoded to a list of strings that were being returned by the OnCall API. Now the values here correspond to the permissions in plugin.json (plus a fallback role)

* changes per Gabriel's comments:
- get rid of group attribute in rbac roles
- remove displayName role attribute
- remove hidden role attribute
- add back role to includes section

* don't try to update user timezone if they don't have permission
2022-11-29 09:41:56 +01:00
Michael Derynck
3582f9b08f
Improve Jinja Template feedback and error handling (#884)
* Improve feedback so template errors are given to user

* Add security error logging

* Add limits for templates, payloads, results

* Show popup error notification for webhook errors and template errors that don't have a result

* Update tests

* Split exceptions into warnings/errors to give more control when previewing, rendering, saving templates

* Limit title lengths

* Make TypeError a warning

* Adjust title length limit

* Remove length limiting on urlize since it is being done on template render

* Fix tests

* Add KeyError and ValueError to warnings

* No longer enforcing json result when saving webhook in case it is dependent on payload

* Add tests for expected exceptions coming from apply_jinja_template

* Update changelog

* Send raw post if template result is not JSON
2022-11-28 09:46:51 -07:00
Vadim Stepanov
54d14d1025
Move MobileAppAuthToken view to mobile_app (#902) 2022-11-28 12:50:58 +00:00
Vadim Stepanov
255964ceaf
Mobile app messaging backend (#874)
* move mobile notifications to a separate backend, remove critical notification

* remove outdated mobile app code

* MOBILE_APP_PUSH_NOTIFICATIONS_ENABLED -> FEATURE_MOBILE_APP_INTEGRATION_ENABLED

* create error log if no devices are set up

* move mobile auth related code to the mobile_app Django app

* move mobile auth related code to the mobile_app Django app

* move mobile auth related code to the mobile_app Django app

* fix typing

* add GCMDevice todos

* add user connection capabilities

* add user connect/disconnect to the messaging backend

* move APNS endpoint to mobile_app Django app

* restore critical notifications

* support hackathon app

* tweak migrations so mobile app auth tokens are preserved

* reuse notify_by IDs

* use mobile app template to render push notification

* add GCM/FCM (Android) support

* fix unlink user

* logger.error -> logger.info
2022-11-23 15:56:43 +00:00
Michael Derynck
81702ba52d Merge dev 2022-11-03 12:42:36 -06:00
Matias Bordese
3e2d52ad51 Update web schedule events to return all-day as datetimes 2022-11-02 16:12:37 -03:00
Michael Derynck
a331a3f392 Rename to validate_settings 2022-11-01 18:24:44 -06:00
Michael Derynck
e019c70f67 Handle validation on update, remove redundant get_error call 2022-11-01 18:22:50 -06:00
Michael Derynck
2905423bad Merge dev 2022-11-01 17:56:03 -06:00
Matias Bordese
64570cc9fd Update schedules endpoint to filter by numeric type 2022-10-31 11:08:33 -03:00
Joey Orlando
5a4c3d6d77
remove POST /api/internal/v1/custom_buttons/{id}/action (#734)
* remove POST /api/internal/v1/custom_buttons/{id}/action
2022-10-28 10:44:37 +02:00
Matias Bordese
565cb84bb1 Add optional type filter to internal schedules endpoint 2022-10-25 12:51:06 -03:00
Innokentii Konstantinov
2c6a27154f
Support mutliregion telegram (#676)
* Support mutliregion telegram

* Fix test_personal_message

* Fix tg verification code tests

* Simplify /start cmd handler

* Comment about link with org_id in tg msg
2022-10-25 14:53:07 +08:00
Matias Bordese
3d171f20f7 Defer large unused queryset fields when listing schedules 2022-10-19 17:07:06 -03:00
Matias Bordese
e4a7a5a23d Rework schedule escalation chains/policies count as a subquery 2022-10-19 17:07:06 -03:00
Vadim Stepanov
e67d3519fe
Restore email notifications (#621)
* remove email verification related code

* remove email verification related code

* remove sendgrid callback

* remove sendgrid related code

* remove sendgrid related code

* rename sendgrid app to email

* remove email from built-in channels

* remove email from built-in channels

* remove email from built-in channels

* add email backend: https://github.com/grafana/oncall/pull/50

* add email templater

* add email templater

* convert md to html

* add email settings to live settings

* use task to send email, handle some exceptions to create logs

* remove ERROR_NOTIFICATION_MAIL_DELIVERY_FAILED usage

* add email limit logic

* fix tests

* add docs

* remove old email templates

* remove old email templates

* add template_fields to messaging backend

* add messaging backends templates to public api

* add comment for deprecated fields

* fix test

* fix tests

* disable email by default

* don't retry on SMTPException and TimeoutError

* add tests

* bring email back to public api docs

* return ERROR_NOTIFICATION_MAIL_LIMIT_EXCEEDED

* make template_fields tuple

* build_subject_and_title -> build_subject_and_message

* add one more comment about template deprecation

* use 8 as backend id

* add comment about gaierror and BadHeaderError

* add comment on importing in notify_user_async

* edit oss docs
2022-10-19 12:32:56 +01:00
Michael Derynck
0152c27f5e Re-validate all twilio settings when any change as they depend on each other 2022-10-18 16:05:49 -06:00
Matias Bordese
f378eab7b7 Allow enabling schedules alpha per organization 2022-10-05 14:06:42 -03:00
Rares Mardare
ea54d21b76 Merge branch 'dev' into 472-wrong-team 2022-09-26 13:34:46 +03:00
Julia
aeb8de96a2 Update comment for wrong_team_response in UserView 2022-09-20 14:47:42 +03:00
Julia
4bcdcfa381 Wrong team error for user page 2022-09-16 11:52:38 +03:00
Julia
7d5636291a Wrong team error for integrations and escalation chains pages 2022-09-12 17:30:45 +03:00
Julia
e4ae10c678 Wrong team error for schedules and custom buttons, add flag to get object from the whole organization 2022-09-12 17:26:23 +03:00
Innokentii Konstantinov
3e8c7a24c8
Add hiding personal phone numbers (#411)
* Add hiding personal phone numbers

* Fix tests

* phone number toggler

* fixed issue where id was not set

* some improvement changes

* show toggle just for validated phone numbers

* ux changes + refactored PhoneVerification

* minor changes

* linter

* hide banner

* ux changes for phone verification

* make it full width

* linter

* show action only if phone is verified

* linter

* revert isCodeSent once phone is forgotten

* fix UserHiddenFieldsSerializer

* await for loadUser

* missing WithPermissions wrapper

Co-authored-by: Rares Mardare <rares.mardare@grafana.com>
Co-authored-by: Rares Mardare <40542072+teodosii@users.noreply.github.com>
2022-09-09 12:42:40 +05:00
Matias Bordese
e5c247cf42 Add name search filter to schedules API 2022-09-07 14:34:43 -03:00
Matias Bordese
02326d81fa
Merge pull request #485 from grafana/matiasb/schedules-related-escalation-chains
Add related escalation chains details to schedule API
2022-09-07 11:17:05 -03:00
Matias Bordese
5a68847557 Refactoring schedule API annotations 2022-09-07 11:12:38 -03:00
Matias Bordese
0a9c9eb59a
Merge pull request #487 from grafana/matiasb/next-shifts-per-user-list-all
Update next shifts per user to list all (web) schedule users
2022-09-07 10:26:28 -03:00
Vadim Stepanov
afe13550da
Alert group search (#488)
* use web title template to render alert group verbose name

* remove group_verbose_name from tests

* clean up group_verbose_name

* remove verbose_name from API & plugin

* verbose_name migration

* update verbose name on web title template change

* use long queue for updating verbose name

* use first alert for updating verbose name

* improve batch_ids

* fix update_verbose_name

* post-review fixes

* post-review fixes
2022-09-06 11:30:12 +01:00
Matias Bordese
d74f4cc2be Update next shifts per user to list all (web) schedule users 2022-09-05 17:23:35 -03:00
Matias Bordese
b41fec5439 Add related escalation chains details to schedule API 2022-09-05 15:00:14 -03:00
Matias Bordese
b5a892a9c2
Merge pull request #381 from grafana/matiasb/fix-final-schedule-event-splitting
Fixes for final event calculation when splitting/combining events
2022-09-05 10:10:11 -03:00
Matias Bordese
37eefe8e08 Allow empty users when previewing a web schedule shift 2022-09-02 16:45:35 -03:00
Matias Bordese
84dd4eebf5 Update shift preview to reuse shift PK when previewing update 2022-09-02 16:45:35 -03:00
Matias Bordese
c84f53c2b7 Handle shift previews for rotation updates 2022-09-02 16:45:35 -03:00
Matias Bordese
11175e27e5 Combine same-shift schedule events early 2022-09-02 16:45:35 -03:00
Matias Bordese
c9ea6e4728 Add web_schedules feature flag 2022-09-02 15:37:33 -03:00
Matias Bordese
6339b13a2f
Merge pull request #423 from grafana/matiasb/unlink-slack-account
Add unlink slack account option to profile
2022-08-30 10:57:36 -03:00
Innokentii Konstantinov
45a2d46405
Fix deletion of public api tokens (#422) 2022-08-30 14:25:19 +01:00
Matias Bordese
6b2dad72d6 Add insight log entry 2022-08-30 09:55:57 -03:00
Matias Bordese
a8124b6afe Add unlink slack account option to profile 2022-08-29 14:41:26 -03:00
Innokentii Konstantinov
356aa336ad
Remove auto-recreating logic for UserNotificationPolicy (#414)
* Remove auto-recreating logic for UserNotificationPolicy

It's removed to get rid of select_for_update on User on each notify_user_task

* Fix and add tests

* remove get_user_policies method
2022-08-26 13:46:50 +05:00
Innokentii Konstantinov
434fe17617
user_id -> linked_user_id (#410) 2022-08-25 13:34:19 +05:00
Innokentii Konstantinov
4765c9b07c
Insight logs (#348)
* Entity events insight logs

* Insight logging

* Fix event for updating templates

* Format fixes

* Remove organization_log_type.py

* Simplify signature of chatops_insight_log

* insight logs formatting

* Add possibility to enable all insight logging via DynamicSetting

* Fixes

* Style fixes

* Add migration

* Fix migration
2022-08-24 12:04:44 +05:00
Matias Bordese
c73df126cc
Merge pull request #359 from grafana/matiasb/messaging-backends-explicit-enum
Make messaging backends enum be defined explicitly
2022-08-22 12:14:46 -03:00
Innokentii Konstantinov
6fb22e0860
Add alert detail view (#385)
* Alert detail view

* Add id to alert serializer
2022-08-19 14:03:07 +05:00
Vadim Stepanov
ed98178b53
Wrong team error for alert groups page (#337)
* WIP

* WIP added stub for getAlert endpoint

* add TeamFilteringMixin

* handle 403 wrong_team for alert group page

* use TeamFilteringMixin only for alert groups

* return original_get_object for schedules and webhooks

* lint

* fix texts

* add support for None in 403 response, add comments

* handle NotFound in retreive

* remove comments

* use HTTP_403_FORBIDDEN

Co-authored-by: Yulia Shanyrova <yulia.shanyrova@grafana.com>
2022-08-17 10:46:53 +03:00
Matias Bordese
5c87b7562c Fix to check for final type in schedule filter_events 2022-08-16 10:50:16 -03:00
Matias Bordese
4477c56b25 Add shift preview endpoint for web schedule 2022-08-16 10:50:16 -03:00