@@ -67,6 +67,7 @@ has_role(actor: AuthenticatedActor, role: String, resource: Resource)
6767# - silo.viewer (can read most resources within the Silo)
6868# - organization.admin (complete control over an organization)
6969# - organization.collaborator (can manage Projects)
70+ # - organization.viewer (can read most resources within the Organization)
7071# - project.admin (complete control over a Project)
7172# - project.collaborator (can manage all resources within the Project)
7273# - project.viewer (can read most resources within the Project)
@@ -164,22 +165,22 @@ resource Organization {
164165 "read" ,
165166 "create_child" ,
166167 ];
167- roles = [ "admin" , "collaborator" ];
168+ roles = [ "admin" , "collaborator" , "viewer" ];
168169
169170 # Roles implied by other roles on this resource
171+ "viewer" if "collaborator" ;
170172 "collaborator" if "admin" ;
171173
172174 # Permissions granted directly by roles on this resource
173- "list_children" if "collaborator " ;
174- "read" if "collaborator " ;
175+ "list_children" if "viewer " ;
176+ "read" if "viewer " ;
175177 "create_child" if "collaborator" ;
176178 "modify" if "admin" ;
177179
178180 # Roles implied by roles on this resource's parent (Silo)
179181 relations = { parent_silo: Silo };
180182 "admin" if "collaborator" on "parent_silo" ;
181- "read" if "viewer" on "parent_silo" ;
182- "list_children" if "viewer" on "parent_silo" ;
183+ "viewer" if "viewer" on "parent_silo" ;
183184}
184185has_relation (silo: Silo , "parent_silo" , organization: Organization )
185186 if organization.silo = silo;
@@ -206,7 +207,7 @@ resource Project {
206207 # Roles implied by roles on this resource's parent (Organization)
207208 relations = { parent_organization: Organization };
208209 "admin" if "collaborator" on "parent_organization" ;
209- "viewer" if "list_children " on "parent_organization" ;
210+ "viewer" if "viewer " on "parent_organization" ;
210211}
211212has_relation (organization: Organization , "parent_organization" , project: Project )
212213 if project.organization = organization;
@@ -253,7 +254,7 @@ has_relation(user: SiloUser, "silo_user", ssh_key: SshKey)
253254# of the API path (e.g., "/images") or as an implementation detail of the system
254255# (in the case of console sessions and "Database"). The policies are
255256# either statically-defined in this file or driven by role assignments on the
256- # Fleet.
257+ # Fleet. None of these resources defines their own roles.
257258#
258259
259260# Describes the policy for accessing "/images" (in the API)
@@ -320,25 +321,11 @@ resource Database {
320321 # other general functions.
321322 "modify"
322323 ];
323- roles = [
324- # All authenticated users get the "user" role, which grants the
325- # "query" permission. See above.
326- "user" ,
327-
328- # The special "db-init" user gets the "init" role, which grants the
329- # additional "modify" permission.
330- "init"
331- ];
332-
333- # See above.
334- "query" if "user" ;
335-
336- "user" if "init" ;
337- "modify" if "init" ;
338324}
339325
340- # All authenticated users have the "user" role on the database.
341- has_role (_actor: AuthenticatedActor , "user" , _resource: Database );
326+ # All authenticated users have the "query" permission on the database.
327+ has_permission (_actor: AuthenticatedActor , "query" , _resource: Database );
328+
342329# The "db-init" user is the only one with the "init" role.
343- has_role (actor: AuthenticatedActor , "init " , _resource: Database )
330+ has_permission (actor: AuthenticatedActor , "modify " , _resource: Database )
344331 if actor = USER_DB_INIT;
0 commit comments