Skip to content

Commit

Permalink
fix: check rules on http resource handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiresviana committed Mar 10, 2021
1 parent 6a734c0 commit 5bf1554
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions http/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 5bf1554

Please sign in to comment.