5151 // admin grants all actions to all resources.
5252 admin : func (_ string ) Role {
5353 return Role {
54- Name : admin ,
54+ Name : admin ,
55+ DisplayName : "Admin" ,
5556 Site : permissions (map [Object ][]Action {
5657 ResourceWildcard : {WildcardSymbol },
5758 }),
6162 // member grants all actions to all resources owned by the user
6263 member : func (_ string ) Role {
6364 return Role {
64- Name : member ,
65+ Name : member ,
66+ DisplayName : "Member" ,
6567 User : permissions (map [Object ][]Action {
6668 ResourceWildcard : {WildcardSymbol },
6769 }),
7375 // TODO: Finish the auditor as we add resources.
7476 auditor : func (_ string ) Role {
7577 return Role {
76- Name : "auditor" ,
78+ Name : "auditor" ,
79+ DisplayName : "Auditor" ,
7780 Site : permissions (map [Object ][]Action {
7881 // Should be able to read all template details, even in orgs they
7982 // are not in.
8689 // organization scope.
8790 orgAdmin : func (organizationID string ) Role {
8891 return Role {
89- Name : roleName (orgAdmin , organizationID ),
92+ Name : roleName (orgAdmin , organizationID ),
93+ DisplayName : "Organization Admin" ,
9094 Org : map [string ][]Permission {
9195 organizationID : {
9296 {
@@ -104,7 +108,8 @@ var (
104108 // in an organization.
105109 orgMember : func (organizationID string ) Role {
106110 return Role {
107- Name : roleName (orgMember , organizationID ),
111+ Name : roleName (orgMember , organizationID ),
112+ DisplayName : "Organization Member" ,
108113 Org : map [string ][]Permission {
109114 organizationID : {},
110115 },
@@ -151,11 +156,11 @@ func IsOrgRole(roleName string) (string, bool) {
151156//
152157// This should be a list in a database, but until then we build
153158// the list from the builtins.
154- func OrganizationRoles (organizationID uuid.UUID ) []string {
155- var roles []string
159+ func OrganizationRoles (organizationID uuid.UUID ) []Role {
160+ var roles []Role
156161 for _ , roleF := range builtInRoles {
157- role := roleF (organizationID .String ()). Name
158- _ , scope , err := roleSplit (role )
162+ role := roleF (organizationID .String ())
163+ _ , scope , err := roleSplit (role . Name )
159164 if err != nil {
160165 // This should never happen
161166 continue
@@ -172,8 +177,8 @@ func OrganizationRoles(organizationID uuid.UUID) []string {
172177//
173178// This should be a list in a database, but until then we build
174179// the list from the builtins.
175- func SiteRoles () []string {
176- var roles []string
180+ func SiteRoles () []Role {
181+ var roles []Role
177182 for _ , roleF := range builtInRoles {
178183 role := roleF ("random" )
179184 _ , scope , err := roleSplit (role .Name )
@@ -182,7 +187,7 @@ func SiteRoles() []string {
182187 continue
183188 }
184189 if scope == "" {
185- roles = append (roles , role . Name )
190+ roles = append (roles , role )
186191 }
187192 }
188193 return roles
0 commit comments