Commit graph

88 commits

Author SHA1 Message Date
Innokentii Konstantinov
61fdcfdc72
Add ratelimit for phone number verification (#1354)
# What this PR does

## Which issue(s) this PR fixes

## Checklist

- [x] Tests updated
- [x] `CHANGELOG.md` updated

---------

Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
2023-02-21 16:47:52 +08:00
Vadim Stepanov
507c9a5b92
Show direct paging integrations in list filter options (#1329)
# What this PR does
Changes the internal API to show direct paging integrations in list
filter options.

<img width="1203" alt="Screenshot 2023-02-15 at 16 27 31"
src="https://user-images.githubusercontent.com/20116910/219090234-d40d471c-ffcc-48e9-8799-e48f03681b72.png">

## Checklist

- [x] Tests updated
2023-02-16 11:38:45 +00:00
Vadim Stepanov
070eb6e538
Enable mobile app backend by default on OSS (#1286)
# What this PR does
Enables mobile app backend by default on OSS.

## Checklist
- [x] `CHANGELOG.md` updated
2023-02-03 12:44:22 +00:00
Matias Bordese
3e15b8cd85
Add default slack channel info to direct paging dialog (#1263) 2023-02-01 10:03:54 -03:00
Vadim Stepanov
f80271a1f4
Return alert group ID in direct paging API (#1241)
# What this PR does
Make direct paging internal API endpoint return an alert group ID.

## Which issue(s) this PR fixes
Related to https://github.com/grafana/oncall/issues/823

## Checklist

- [x] Tests updated
2023-01-30 11:48:25 +00:00
Vadim Stepanov
2b0abf018c
Hide direct paging integrations (#1162)
# What this PR does
Hide direct paging integrations from the web UI. Related to
https://github.com/grafana/oncall/issues/823

## Checklist

- [x] Tests updated
- [ ] Documentation added (N/A)
- [ ] `CHANGELOG.md` updated (N/A)
2023-01-20 13:29:57 +00:00
Vadim Stepanov
ccae9d86b3
Add an ability to use an escalation chain for direct paging (#1161)
# What this PR does
Adds an ability to page an escalation chain for a newly created direct
paging alert group using the internal API. Also [adds a forgotten
migration](32fc44e744)
related to the direct paging backend.
Related to https://github.com/grafana/oncall/issues/823

## Checklist

- [x] Tests updated
- [ ] Documentation added (N/A)
- [ ] `CHANGELOG.md` updated (N/A)
2023-01-19 18:51:57 +00:00
Vadim Stepanov
b8d78fd6bb
Allow messaging backends to be enabled/disabled per organization (#1151)
# What this PR does
Allows messaging backends to be enabled/disabled per organization when
getting a list of available personal notification channels.

## Checklist

- [x] Tests updated
- [ ] Documentation added (N/A)
- [x] `CHANGELOG.md` updated
2023-01-18 15:52:25 +00:00
Matias Bordese
d3062b56fd
Draft initial logic for user/schedule paging (#1098)
Co-authored-by: Vadim Stepanov <vadimkerr@gmail.com>
2023-01-17 12:19:08 -03:00
Matias Bordese
0d38fe2a7f
Web schedules overrides are the higher priority level (#1115)
Related to https://github.com/grafana/oncall-private/issues/1550
2023-01-13 08:58:35 -03:00
Matias Bordese
374f32f489 Handle no start date when calculating by day ical shift events 2023-01-02 11:53:49 -03:00
Matias Bordese
67ac47ff32 Update SCHEDULES_WRITE fallback role to EDITOR 2022-12-09 12:56:35 -03:00
Joey Orlando
f8c8ceb2f6
only grant admins read/write access to public api keys (#952) 2022-12-06 13:02:53 +01:00
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
dc6fcf5c05
Add internal API fields for the mobile app (#910)
* add permalinks list to internal API alertgroup view

* add user's name and full avatar URL to the user view

* make avatar_full_url a property

* fix tests

* fix user connection criteria
2022-11-28 15:52:31 +00:00
Innokentii Konstantinov
3b73522f5a
Fix saving source link template (#898)
* Add test for update integration templates

* Fix saving source link template
2022-11-24 16:26:12 +08:00
Matias Bordese
98b187acd9 Add support for daily/by-day and custom interval 2022-11-02 16:12:16 -03:00
Matias Bordese
4bc3ed17a8 Make interval check more explicit 2022-11-02 16:12:16 -03:00
Matias Bordese
241283959a Enable daily/by-day shifts option for web schedules 2022-11-02 16:12:16 -03: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
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
Ben Sully
e36757b293
Allow non-JSON custom webhook templates, provided they render as valid JSON (#639)
* Allow non-JSON custom webhook templates, provided they render as valid JSON

Previously, both the provided template _and_ the rendered template had
to be valid JSON in order for validation to pass. This was unnecessarily
restrictive: really, only the rendered template needs to be valid JSON.
It also disallowed using templates such as:

    {
      "labels": {{ alert_payload.labels | tojson }}
    }

even though this would be valid JSON after rendering.

This commit relaxes the validation of custom webhook templates so that
they don't need to be valid JSON, provided that the rendered template
_is_ valid JSON. This is checked using a dummy dictionary of render
params, which use a constant string for the `alert_group_id` field
and a `defaultdict(dict)` for the `alert_payload` field. This should
permit templates like the one above, but still deny templates such as

    {
      "labels": {{ alert_payload.labels }}
    }

which would otherwise fail later if `labels` is not valid JSON.

This should resolve #638.

* Use defaultdict(str) instead of defaultdict(lambda: "")

* Add missing comment to resolution note validation code

* Update validation of resolution notes in public API, too

* Add extra test cases for JSON webhook templates endpoint of public API
2022-10-19 12:32:21 +01:00
Matias Bordese
2a3fc397db Clear users cache before schedule tests logic/asserts 2022-10-03 15:00:23 -03:00
Matias Bordese
f8314ef9c2
Fix timing issue with schedule tests reusing cached users (#592)
Co-authored-by: Vadim Stepanov <vadimkerr@gmail.com>
2022-10-03 11:37:59 +01:00
Rares Mardare
ea54d21b76 Merge branch 'dev' into 472-wrong-team 2022-09-26 13:34:46 +03:00
Maxim Mordasov
9330b89101
Schedules alpha fixes (#541)
* schedule alpha major fixes

* Fix shift update for web schedules

* Fix priority level regex, fix getting shifts without duration

* Fix shift update for web schedules

* Fix tests for shift update

* Fix priority level test

* schedule alpha fixes

* add final schedule click handler

* fix date time picker

* fix utc timzeonr time picker

* fix utc time data

* dont use user timezone on start

Co-authored-by: Julia <ferril.darkdiver@gmail.com>
2022-09-21 11:19:59 +01:00
Julia
c92faf23c6 Add tests for wrong team for user 2022-09-16 11:53:47 +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
Julia
67eb0b423d Merge branch 'dev' into on-call-shifts-rotation-index
# Conflicts:
#	engine/apps/schedules/models/on_call_schedule.py
2022-09-08 16:43:35 +03:00
Matias Bordese
2d13f9116b Update shift preview to return events for (all) affected shifts 2022-09-08 09:33:51 -03:00
Matias Bordese
a4c036d5aa Update preview rotation start logic to match update logic 2022-09-07 15:37:03 -03:00
Julia
9f71b5d72f Merge branch 'dev' into on-call-shifts-rotation-index 2022-09-07 18:54:39 +03:00
Matias Bordese
026474b43b
Merge pull request #486 from grafana/matiasb/update-preview-shift-pk-reuse
Update web schedule shift preview PK reusing logic
2022-09-07 11:35:34 -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
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
Matias Bordese
b48aadc01c
Merge pull request #473 from grafana/matiasb/fix-update-channel-filter-api-multiple-backends
Fix channel filter updates when there are multiple backends
2022-09-06 17:14:07 -03: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
c413c54329 Update web schedule shift preview PK reusing logic 2022-09-05 15:50:58 -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
7fd0e5ecf7 Skip empty events in final schedule 2022-09-02 16:45:35 -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