shouldCheckAdminRBAC returns true if the request needs to check the server for permissions to run
()
| 290 | |
| 291 | // shouldCheckAdminRBAC returns true if the request needs to check the server for permissions to run |
| 292 | func (h *handler) shouldCheckAdminRBAC() bool { |
| 293 | sgcollectToken := h.server.SGCollect.getToken(h.rq.Header) |
| 294 | if sgcollectToken != "" && h.sgcollect && h.server.SGCollect.hasValidToken(h.ctx(), sgcollectToken) { |
| 295 | return false |
| 296 | } |
| 297 | if h.privs == adminPrivs && *h.server.Config.API.AdminInterfaceAuthentication { |
| 298 | if sgcollectToken != "" && !h.sgcollect { |
| 299 | base.AssertfCtx(h.ctx(), sgcollectTokenInvalidRequest) |
| 300 | } |
| 301 | return true |
| 302 | } else if h.privs == metricsPrivs && *h.server.Config.API.MetricsInterfaceAuthentication { |
| 303 | return true |
| 304 | } |
| 305 | return false |
| 306 | } |
| 307 | |
| 308 | // validateAndWriteHeaders sets up handler.db and validates the permission of the user and returns an error if there is not permission. |
| 309 | func (h *handler) validateAndWriteHeaders(method handlerMethod, accessPermissions []Permission, responsePermissions []Permission) (err error) { |