Skip to content

Commit

Permalink
check status codes (#1297)
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
  • Loading branch information
butonic authored Nov 9, 2020
1 parent ffba160 commit f1dd416
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/ocdav-check-status-code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: check the err and the response status code

The publicfile handler needs to check the response status code to return proper not pound and permission errors in the webdav api.

https://github.com/cs3org/reva/pull/1297
27 changes: 27 additions & 0 deletions internal/http/services/owncloud/ocdav/publicfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"net/http"
"path"

rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/rhttp/router"
Expand Down Expand Up @@ -106,6 +107,19 @@ func (s *svc) adjustResourcePathInURL(w http.ResponseWriter, r *http.Request) bo
w.WriteHeader(http.StatusNotFound)
return false
}
if pathRes.Status.Code != rpc.Code_CODE_OK {
switch pathRes.Status.Code {
case rpc.Code_CODE_NOT_FOUND:
w.WriteHeader(http.StatusNotFound)
return false
case rpc.Code_CODE_PERMISSION_DENIED:
w.WriteHeader(http.StatusForbidden)
return false
default:
w.WriteHeader(http.StatusInternalServerError)
return false
}
}
if path.Base(r.URL.Path) != path.Base(pathRes.Path) {
w.WriteHeader(http.StatusNotFound)
return false
Expand Down Expand Up @@ -165,6 +179,19 @@ func (s *svc) handlePropfindOnToken(w http.ResponseWriter, r *http.Request, ns s
w.WriteHeader(http.StatusNotFound)
return
}
if pathRes.Status.Code != rpc.Code_CODE_OK {
switch pathRes.Status.Code {
case rpc.Code_CODE_NOT_FOUND:
w.WriteHeader(http.StatusNotFound)
return
case rpc.Code_CODE_PERMISSION_DENIED:
w.WriteHeader(http.StatusForbidden)
return
default:
w.WriteHeader(http.StatusInternalServerError)
return
}
}

infos := []*provider.ResourceInfo{}

Expand Down

0 comments on commit f1dd416

Please sign in to comment.