package role const ( OwnerName = "Owner" AdminName = "Admin" WriterName = "Writer" ) func allGrants(include func(Permission) bool) []Grant { grants := []Grant{} for _, permission := range catalogue { if include(permission) { grants = append(grants, Grant{Key: permission.Key, Scope: ScopeAll}) } } return grants } func writerGrants() []Grant { return []Grant{ {Key: KeyContentRead, Scope: ScopeAll}, {Key: KeyContentCreate, Scope: ScopeAll}, {Key: KeyContentUpdate, Scope: ScopeAll}, {Key: KeySchemaView, Scope: ScopeAll}, {Key: KeyMediaView, Scope: ScopeAll}, {Key: KeyMediaUpload, Scope: ScopeAll}, {Key: KeyAuthorsView, Scope: ScopeAll}, {Key: KeyAuthorsEdit, Scope: ScopeOwn}, {Key: KeyActivityView, Scope: ScopeOwn}, } } func BuiltInRoles() []Role { return []Role{ { Name: OwnerName, BuiltIn: true, Locked: true, Version: 1, Grants: allGrants(func(Permission) bool { return true }), }, { Name: AdminName, BuiltIn: true, Version: 1, Grants: allGrants(func(p Permission) bool { return !p.OwnerOnly }), }, { Name: WriterName, BuiltIn: true, Version: 1, Grants: writerGrants(), }, } }