MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / shouldCheckAdminRBAC

Method shouldCheckAdminRBAC

rest/handler.go:292–306  ·  view source on GitHub ↗

shouldCheckAdminRBAC returns true if the request needs to check the server for permissions to run

()

Source from the content-addressed store, hash-verified

290
291// shouldCheckAdminRBAC returns true if the request needs to check the server for permissions to run
292func (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.
309func (h *handler) validateAndWriteHeaders(method handlerMethod, accessPermissions []Permission, responsePermissions []Permission) (err error) {

Callers 2

TestShouldCheckAdminRBACFunction · 0.80

Calls 4

ctxMethod · 0.95
AssertfCtxFunction · 0.92
getTokenMethod · 0.80
hasValidTokenMethod · 0.80

Tested by 1

TestShouldCheckAdminRBACFunction · 0.64