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

Method initRole

auth/role.go:112–130  ·  view source on GitHub ↗
(name string, channels base.Set, collections map[string]map[string]struct{})

Source from the content-addressed store, hash-verified

110}
111
112func (role *roleImpl) initRole(name string, channels base.Set, collections map[string]map[string]struct{}) error {
113 role.Name_ = name
114 // Grant the user the specified channels for all specified collections. If none are
115 // specified, grant to the default collection.
116 if len(collections) == 0 {
117 if err := role.initChannels(base.DefaultScope, base.DefaultCollection, channels); err != nil {
118 return err
119 }
120 } else {
121 for scopeName, scope := range collections {
122 for collectionName, _ := range scope {
123 if err := role.initChannels(scopeName, collectionName, channels); err != nil {
124 return err
125 }
126 }
127 }
128 }
129 return role.validate()
130}
131
132// IsValidPrincipalName checks if the given user/role name would be valid. Valid names must be valid UTF-8, containing
133// at least one alphanumeric (except for the guest user), and no colons, commas, backticks, or slashes.

Callers 5

TestInitRoleFunction · 0.95
NewRoleMethod · 0.95
NewRoleNoChannelsMethod · 0.95
NewUserMethod · 0.80
NewUserNoChannelsMethod · 0.80

Calls 2

initChannelsMethod · 0.95
validateMethod · 0.95

Tested by 1

TestInitRoleFunction · 0.76