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

Function getCBUserRolesForAudit

rest/handler.go:706–725  ·  view source on GitHub ↗
(db *db.DatabaseContext, authScope string, ctx context.Context, httpClient *http.Client, managementEndpoints []string, username, password string)

Source from the content-addressed store, hash-verified

704}
705
706func getCBUserRolesForAudit(db *db.DatabaseContext, authScope string, ctx context.Context, httpClient *http.Client, managementEndpoints []string, username, password string) []string {
707 if !needRolesForAudit(db, base.UserDomainCBServer) {
708 return nil
709 }
710
711 whoAmIResponse, whoAmIStatus, whoAmIErr := cbRBACWhoAmI(ctx, httpClient, managementEndpoints, username, password)
712 if whoAmIErr != nil || whoAmIStatus != http.StatusOK {
713 base.WarnfCtx(ctx, "An error occurred whilst fetching the user's roles for audit filtering - will not filter: %v", whoAmIErr)
714 return nil
715 }
716
717 var auditRoleNames []string
718 for _, role := range whoAmIResponse.Roles {
719 // only filter roles applied to this bucket or cluster-scope
720 if role.BucketName == "" || role.BucketName == authScope {
721 auditRoleNames = append(auditRoleNames, role.RoleName)
722 }
723 }
724 return auditRoleNames
725}
726
727// removeCorruptConfigIfExists will remove the config from the bucket and remove it from the map if it exists on the invalid database config map
728func (h *handler) removeCorruptConfigIfExists(ctx context.Context, bucket, configGroupID, dbName string) error {

Callers 1

Calls 3

WarnfCtxFunction · 0.92
needRolesForAuditFunction · 0.85
cbRBACWhoAmIFunction · 0.85

Tested by

no test coverage detected