Alerting: Stop returning autogen routes for non-admin on api/v2/status (#84864)

* Alerting: Stop returning autogen routes for non-admin on api/v2/status

* Improve api/v2/status integration tests for user roles
This commit is contained in:
Matthew Jacobson
2024-03-20 22:04:35 +02:00
committed by GitHub
parent 7eee34311d
commit fbd057b258
3 changed files with 125 additions and 17 deletions
+6 -1
View File
@@ -50,7 +50,12 @@ func (srv AlertmanagerSrv) RouteGetAMStatus(c *contextmodel.ReqContext) response
return errResp
}
return response.JSON(http.StatusOK, am.GetStatus())
status := am.GetStatus()
if !c.SignedInUser.HasRole(org.RoleAdmin) {
notifier.RemoveAutogenConfigIfExists(status.Config.Route)
}
return response.JSON(http.StatusOK, status)
}
func (srv AlertmanagerSrv) RouteCreateSilence(c *contextmodel.ReqContext, postableSilence apimodels.PostableSilence) response.Response {