Skip to content

Commit

Permalink
return 404 when no permission to space (#3368)
Browse files Browse the repository at this point in the history
* return 404 when no permission to space

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* make share jail return 409

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic committed Oct 18, 2022
1 parent 85e3e5c commit 203cc6b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/return-conflict-vs-notfound.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: return 404 when no permission to space

WebDAV expects a 409 response when trying to upload into a non existing folder. We fixed the implementation to return 404 when a user has no access to a space and still return a 409 when a parent folder does not exist (and he has access to the space).

https://github.com/cs3org/reva/pull/3368
https://github.com/cs3org/reva/pull/3300
https://github.com/owncloud/ocis/issues/3561
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,15 @@ func (s *service) InitiateFileUpload(ctx context.Context, req *provider.Initiate
Interface("ref", req.Ref).
Interface("received_share", receivedShare).
Msg("sharesstorageprovider: Got InitiateFileUpload request")
if err != nil {
switch {
case err != nil:
return nil, err
}
if rpcStatus.Code != rpc.Code_CODE_OK {
case rpcStatus.Code == rpc.Code_CODE_NOT_FOUND:
// the user has access (it showed up in the clist of shares), but we cannot write here
return &provider.InitiateFileUploadResponse{
Status: status.NewFailedPrecondition(ctx, nil, rpcStatus.GetMessage()),
}, nil
case rpcStatus.Code != rpc.Code_CODE_OK:
return &provider.InitiateFileUploadResponse{
Status: rpcStatus,
}, nil
Expand Down
2 changes: 1 addition & 1 deletion internal/http/services/owncloud/ocdav/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (s *svc) handlePut(ctx context.Context, w http.ResponseWriter, r *http.Requ
case rpc.Code_CODE_FAILED_PRECONDITION:
w.WriteHeader(http.StatusConflict)
case rpc.Code_CODE_NOT_FOUND:
w.WriteHeader(http.StatusConflict)
w.WriteHeader(http.StatusNotFound)
default:
errors.HandleErrorStatus(&log, w, uRes.Status)
}
Expand Down
7 changes: 6 additions & 1 deletion pkg/storage/utils/decomposedfs/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,12 @@ func (fs *Decomposedfs) InitiateUpload(ctx context.Context, ref *provider.Refere
log := appctx.GetLogger(ctx)

n, err := fs.lu.NodeFromResource(ctx, ref)
if err != nil {
switch err.(type) {
case nil:
// ok
case errtypes.IsNotFound:
return nil, errtypes.PreconditionFailed(err.Error())
default:
return nil, err
}

Expand Down

0 comments on commit 203cc6b

Please sign in to comment.