@@ -58,7 +58,8 @@ func (q *AuthzQuerier) GetTemplateVersionByID(ctx context.Context, tvid uuid.UUI
58
58
// An actor can read the template version if they can read the related template.
59
59
fetchRelated := func (tv database.TemplateVersion , _ uuid.UUID ) (rbac.Objecter , error ) {
60
60
if ! tv .TemplateID .Valid {
61
- // If no linked template exists, check if the actor can read a template in the organization.
61
+ // If no linked template exists, check if the actor can read a template
62
+ // in the organization.
62
63
return rbac .ResourceTemplate .InOrg (tv .OrganizationID ), nil
63
64
}
64
65
return q .database .GetTemplateByID (ctx , tv .TemplateID .UUID )
@@ -73,7 +74,12 @@ func (q *AuthzQuerier) GetTemplateVersionByID(ctx context.Context, tvid uuid.UUI
73
74
74
75
func (q * AuthzQuerier ) GetTemplateVersionByJobID (ctx context.Context , jobID uuid.UUID ) (database.TemplateVersion , error ) {
75
76
// An actor can read the template version if they can read the related template.
76
- fetchRelated := func (tv database.TemplateVersion , _ uuid.UUID ) (database.Template , error ) {
77
+ fetchRelated := func (tv database.TemplateVersion , _ uuid.UUID ) (rbac.Objecter , error ) {
78
+ if ! tv .TemplateID .Valid {
79
+ // If no linked template exists, check if the actor can read a
80
+ // template in the organization.
81
+ return rbac .ResourceTemplate .InOrg (tv .OrganizationID ), nil
82
+ }
77
83
return q .database .GetTemplateByID (ctx , tv .TemplateID .UUID )
78
84
}
79
85
return authorizedQueryWithRelated (
0 commit comments