Alerting: Update rule access control to return errutil errors (#78284)

* update rule access control to return errutil errors
* use alerting in msgID
This commit is contained in:
Yuri Tseretyan
2023-12-02 01:42:11 +02:00
committed by GitHub
parent 6644e5e676
commit 64feeddc23
12 changed files with 187 additions and 102 deletions
+5 -1
View File
@@ -235,7 +235,11 @@ func (srv PrometheusSrv) RouteGetRuleStatuses(c *contextmodel.ReqContext) respon
srv.log.Warn("Query returned rules that belong to folder the user does not have access to. All rules that belong to that namespace will not be added to the response", "folder_uid", groupKey.NamespaceUID)
continue
}
if !srv.authz.AuthorizeAccessToRuleGroup(c.Req.Context(), c.SignedInUser, rules) {
ok, err := srv.authz.HasAccessToRuleGroup(c.Req.Context(), c.SignedInUser, rules)
if err != nil {
return response.ErrOrFallback(http.StatusInternalServerError, "cannot authorize access to rule group", err)
}
if !ok {
continue
}
ruleGroup, totals := srv.toRuleGroup(groupKey, folder, rules, limitAlertsPerRule, withStatesFast, matchers, labelOptions)