Commit Graph

35 Commits

Author SHA1 Message Date
Yuriy Tseretyan
54fa04263b
Alerting: Add RBAC actions and role for provisioning API routes (#50459)
* add alert provisioning actions and role

* linter
2022-06-09 09:18:57 +02:00
Alexander Weaver
28a47b56d2
Bump provisioning to admin-only in lieu of dedicated RBAC permissions (#50366) 2022-06-07 17:26:48 -05:00
Alexander Weaver
67290aa49f
Alerting: Add version segment to all provisioning routes (#49121)
Co-authored-by: Jean-Philippe Quémémer <jeanphilippe.quemener@grafana.com>
2022-06-03 16:45:08 +02:00
Gilles De Mey
e6ceee501f
Alerting: Use correct permission scope for external AM updates (#50159)
Co-authored-by: konrad147 <konrad.lalik@grafana.com>
2022-06-03 15:12:34 +02:00
Jean-Philippe Quéméner
468ed68d64
Alerting: allow custom UID for contact points through API (#50089)
* Alerting: allow custom UID for contact points through API

* fix auth
2022-06-03 10:33:47 +02:00
Jean-Philippe Quéméner
81d360529b
Alerting: Provisioning API - Alert rules (#47930) 2022-06-02 14:48:53 +02:00
Yuriy Tseretyan
ad25e2a20c
Alerting: Update RBAC for alert rules to consider access to rule as access to group it belongs (#49033)
* update authz to exclude entire group if user does not have access to rule
* change rule update authz to not return changes because if user does not have access to any rule in group, they do not have access to the rule
* a new query that returns alerts in group by UID of alert that belongs to that group
* collect all affected groups during calculate changes
* update authorize to check access to groups
* update tests for calculateChanges to assert new fields
* add authorization tests
2022-06-01 10:23:54 -04:00
Alexander Weaver
909ebcf979
Alerting: Endpoints for provisioning mute timings (#49635)
* Add validator for mute timing and make it provisionable

* Add tests to ensure prometheus validators are running and errors are propagated

* Internal API for manipulating mute timings

* Define and generate API layer

* Wire up generated code

* Implement API handlers

* Tests for golang layer

* Fix reference bug

* Fix linter and auth tests

* Resolve semantic errors and regenerate

* Remove pointless comment

* Extract out provisioning path param keys, simplify

* Expected number of paths
2022-05-26 14:24:34 -05:00
Yuriy Tseretyan
3dfafbadef
Alerting: Fix access to alerts for viewer with editor permissions when RBAC is disabled (#49270)
* Add folder edit permission for users with Viewer role
* relax permissions required to create an alert when RBAC is disabled
2022-05-23 09:58:20 -04:00
Yuriy Tseretyan
258b3ab18b
Alerting: Fix RBAC actions for notification policies (#49185)
* squash actions "alert.notifications:update", "alert.notifications:create", "alert.notifications:delete" to "alert.notifications:write"
* add migration
* update UI to use the write action
* update docs
* changelog
2022-05-20 10:55:07 -04:00
Alexander Weaver
9af30f6570
Alerting: Provisioning GET routes for mute timings (#49044)
* Define GET routes and run codegen

* Wire up forked and non-generated API

* Implement and wire

* Tests, authorization

* Fix linter error
2022-05-17 13:42:48 -05:00
Sofia Papagiannaki
925784f514
Alerting: Modify endpoint for testing a datasource rule using the UID (#48070)
* Modify testing endpoint to expect the datasource UID

* Update docs
2022-05-17 14:10:20 +03:00
Yuriy Tseretyan
952cb4fc0b
Alerting: introduce AlertRuleGroupKey and use it in API handlers (#48945)
* create AlertGroupKey structure
* update PrometheusSrv.
  - extract creation of RuleGroup to a separate method. Use group key for grouping
* update RuleSrv 
 - update calculateChanges to use groupKey
 - authorize to use groupkey
2022-05-16 15:45:45 -04:00
Yuriy Tseretyan
e528f2e430
Alerting: Use UID scope for folders authorization (#48970) 2022-05-13 18:05:25 +02:00
Alexander Weaver
99eaa0fc20
Put identifier in path (#48831) 2022-05-06 16:06:30 -05:00
Alexander Weaver
809aa38103
POST routes to PUT routes (#48828) 2022-05-06 14:33:30 -05:00
Sofia Papagiannaki
bb66c03f9a
Alerting: modify prometheus endpoints for proxying using the datasource UID (#48052)
* Modify prometheus endpoints to expect the data source UID

* Update frontend
2022-05-06 15:05:02 -04:00
Alexander Weaver
0f56462fbe
Alerting: Provisioning message templates (#48665)
* Generate API for writing templates

* Persist templates app logic layer

* Validate templates

* Extract logic, make set and delete methods

* Drop post route for templates

* Fix response details, wire up remainder of API

* Authorize routes

* Mirror some existing tests on new APIs

* Generate mock for prov store

* Wire up prov store mock, add tests using it

* Cover cases for both storage paths

* Add happy path tests and fix bugs if file contains no template section

* Normalize template content with define statement

* Tests for deletion

* Fix linter error

* Move provenance field to DTO

* empty commit

* ID to name

* Fix in auth too
2022-05-05 15:21:42 -05:00
Sofia Papagiannaki
610247d52a
Alerting: modify ruler endpoints for proxying using the datasource UID (#48046)
* Modify ruler endpoints to expect the data source UID

* Update frontend

* Apply suggestion from code review
2022-05-05 14:58:32 +03:00
Sofia Papagiannaki
3e752a0db1
Alerting: modify alertmanager endpoints for proxying using the datasource UID (#47978)
* Alerting: enable proxying alertmanager calls using the datasource UID

* Remove use of datasource ID from the API

* Update frontend
2022-04-29 10:25:22 +03:00
Alexander Weaver
735822e48a
Alerting: Add provisioning GET routes for message templates (#48367)
* Template service

* Add GET routes and implement them

* Generate mock for persist layer

* Unit tests for reading templates

* Set up composition root and get integration tests working

* Fix prealloc issue

* Extract setup boilerplate

* Update AuthorizationTest

* Rebase and resolve

* Fix linter error
2022-04-28 13:51:57 -05:00
Karl Persson
e9a93ebfc9
Access Control: Move access control middlewares to domain package (#48322)
* Move access control middleware to domain package
2022-04-28 10:46:18 +02:00
Sofia Papagiannaki
54962c2f0c
Alerting: Rename Recipient path parameter to DatasourceID (#47949) 2022-04-20 16:20:17 +03:00
Jean-Philippe Quéméner
388ecb4037
Alerting: Provisioning API - Contact points (#47197) 2022-04-13 22:15:55 +02:00
Alexander Weaver
dde0b93cf1
Alerting: Provisioning API - Notification Policies (#46755)
* Base-line API for provisioning notification policies

* Wire API up, some simple tests

* Return provenance status through API

* Fix missing call

* Transactions

* Clarity in package dependencies

* Unify receivers in definitions

* Fix issue introduced by receiver change

* Drop unused internal test implementation

* FGAC hooks for provisioning routes

* Polish, swap names

* Asserting on number of exposed routes

* Don't bubble up updated object

* Integrate with new concurrency token feature in store

* Back out duplicated changes

* Remove redundant tests

* Regenerate and create unit tests for API layer

* Integration tests for auth

* Address linter errors

* Put route behind toggle

* Use alternative store API and fix feature toggle in tests

* Fixes, polish

* Fix whitespace

* Re-kick drone

* Rename services to provisioning
2022-04-05 16:48:51 -05:00
Yuriy Tseretyan
c1dbe7617c
fix scope for datasource:query action (#46973) 2022-03-29 09:58:59 -04:00
Yuriy Tseretyan
15e4556c2f
Alerting: update authorization logic to use proper legacy roles when fine-grained access is disabled (#46931)
* require legacy Editor for post, put, delete endpoints
* require user to be signed in on group level because handler that checks that user has role Editor does not check it is signed in
2022-03-24 17:13:47 -04:00
Yuriy Tseretyan
8868848e93
Alerting: rule group update API to ignore deletes of rules user is not authorized to access (#46905)
* verify that the user has access to all data sources used by the rule that needs to be deleted from the group
* if a user is not authorized to access the rule, the rule is removed from the list to delete
2022-03-24 16:53:00 -04:00
Yuriy Tseretyan
acd7be1cb4
Alerting: Change getEvaluatorForAlertRule to checkDatasourcePermissionsForRule (#46887)
update method getEvaluatorForAlertRule to accept permissions evaluator and exit on the first negative result, which is more effective than returning an evaluator that in fact is a bunch of slices.
2022-03-23 17:11:30 +00:00
Yuriy Tseretyan
2ade8b56dd
Alerting: support fine-grained access control in ruler update API (#45749)
* require Editor if FGAC is disabled. Otherwise, check `alert.rule:*` + `datasource:query` permissions when user changes rules.
2022-03-21 19:20:35 -04:00
Karl Persson
2727e2503f
Use corrct variable names (#46647) 2022-03-16 16:18:45 +01:00
Yuriy Tseretyan
c42d2e6f5d
Alerting: Add support for fine-grained access to alerting APIs (#46561) 2022-03-16 09:36:58 -04:00
Yuriy Tseretyan
468def0c00
Alerting: fixed roles for fine-grained access control (#46553)
* move alerting actions to accesscontrol to avoid cycledeps
* define new actions and fixed roles for alerting
* add folder permission to alert reader role
2022-03-15 14:30:32 -04:00
Yuriy Tseretyan
f7894db99c
Alerting: declare authorization actions, scopes and roles for fine-grained access (#45748)
* add actions, roles and route mapping for rule permission
* add instance\notification actions
* do not declare alerting roles if no feature flag is set (temporary)
2022-03-08 09:22:16 -05:00
Yuriy Tseretyan
ddfe2dce74
Alerting: Split grafana and lotex routes (#44742)
* split Lotex and Grafana routes
* update template to use authorize function for every route
2022-02-04 12:42:04 -05:00