feat: Move create organizations route (#1831)

* feat: last rbac routes
- move create organization to /organizations.
This commit is contained in:
Steven Masley
2022-05-27 11:19:13 -05:00
committed by GitHub
parent d73a0f4f23
commit ec1fe46138
12 changed files with 150 additions and 108 deletions

View File

@ -310,6 +310,7 @@ func (api *API) postTemplateVersionsByOrganization(rw http.ResponseWriter, r *ht
if !httpapi.Read(rw, r, &req) {
return
}
if req.TemplateID != uuid.Nil {
_, err := api.Database.GetTemplateByID(r.Context(), req.TemplateID)
if errors.Is(err, sql.ErrNoRows) {
@ -340,6 +341,15 @@ func (api *API) postTemplateVersionsByOrganization(rw http.ResponseWriter, r *ht
return
}
// Making a new template version is the same permission as creating a new template.
if !api.Authorize(rw, r, rbac.ActionCreate, rbac.ResourceTemplate.InOrg(organization.ID)) {
return
}
if !api.Authorize(rw, r, rbac.ActionRead, file) {
return
}
var templateVersion database.TemplateVersion
var provisionerJob database.ProvisionerJob
err = api.Database.InTx(func(db database.Store) error {