Alerting API: Restrict access to Alertmanager configuration (#36507)

* Alerting API: Restrict access to Alertmanager configuration to viewers
This commit is contained in:
Sofia Papagiannaki
2021-07-07 16:29:18 +03:00
committed by GitHub
parent eed1f36613
commit fc90d47863
2 changed files with 74 additions and 0 deletions
@@ -64,6 +64,9 @@ func (srv AlertmanagerSrv) RouteDeleteSilence(c *models.ReqContext) response.Res
}
func (srv AlertmanagerSrv) RouteGetAlertingConfig(c *models.ReqContext) response.Response {
if !c.HasUserRole(models.ROLE_EDITOR) {
return ErrResp(http.StatusForbidden, errors.New("permission denied"), "")
}
query := ngmodels.GetLatestAlertmanagerConfigurationQuery{}
if err := srv.store.GetLatestAlertmanagerConfiguration(&query); err != nil {
if errors.Is(err, store.ErrNoAlertmanagerConfiguration) {