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

Function getSGUserRolesForAudit

rest/handler.go:889–912  ·  view source on GitHub ↗

getSGUserRolesForAudit returns a list of role names for the given user, if audit role filtering is enabled.

(db *db.DatabaseContext, user auth.User)

Source from the content-addressed store, hash-verified

887
888// getSGUserRolesForAudit returns a list of role names for the given user, if audit role filtering is enabled.
889func getSGUserRolesForAudit(db *db.DatabaseContext, user auth.User) ([]string, error) {
890 if user == nil {
891 return nil, nil
892 }
893
894 if !needRolesForAudit(db, base.UserDomainSyncGateway) {
895 return nil, nil
896 }
897
898 roles, err := user.GetRoles()
899 if err != nil {
900 return nil, err
901 }
902 if len(roles) == 0 {
903 return nil, nil
904 }
905
906 roleNames := make([]string, 0, len(roles))
907 for _, role := range roles {
908 roleNames = append(roleNames, role.Name())
909 }
910
911 return roleNames, nil
912}
913
914// checkPublicAuth verifies that the current request is authenticated for the given database. Returns an HTTPError if
915// authentication fails.

Callers 1

checkPublicAuthMethod · 0.85

Calls 3

needRolesForAuditFunction · 0.85
GetRolesMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected