From 5bf15548d0ad147acfad5000277531be2671f7ce Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Wed, 10 Mar 2021 17:38:11 +0000 Subject: [PATCH] fix: check rules on http resource handlers --- http/resource.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/http/resource.go b/http/resource.go index 84a5abf8..2547a2ed 100644 --- a/http/resource.go +++ b/http/resource.go @@ -91,7 +91,7 @@ func resourceDeleteHandler(fileCache FileCache) handleFunc { func resourcePostHandler(fileCache FileCache) handleFunc { return withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) { - if !d.user.Perm.Create { + if !d.user.Perm.Create || !d.Check(r.URL.Path) { return http.StatusForbidden, nil } @@ -141,7 +141,7 @@ func resourcePostHandler(fileCache FileCache) handleFunc { } var resourcePutHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) { - if !d.user.Perm.Modify { + if !d.user.Perm.Modify || !d.Check(r.URL.Path) { return http.StatusForbidden, nil } @@ -174,6 +174,9 @@ var resourcePatchHandler = withUser(func(w http.ResponseWriter, r *http.Request, dst := r.URL.Query().Get("destination") action := r.URL.Query().Get("action") dst, err := url.QueryUnescape(dst) + if !d.Check(src) || !d.Check(dst) { + return http.StatusForbidden, nil + } if err != nil { return errToStatus(err), err }