Skip to content

Commit

Permalink
fix: dav delete via resource id
Browse files Browse the repository at this point in the history
Fixes an issue where deleting a resource via its id, using the `/dav/spaces/{fileId}` endpoint, wouldn't work.

The issue was happening because the code was checking for an empty path to prevent spaces from being deleted this way (because spaces have an empty path). When only providing a resource id however, the path will be empty for regular resources as well. For this reason we now additionally check for the resource's `opaqueId`. If the resource doesn't have such and the path is empty, we can assume that it's a space and prevent deletion via the dav endpoint.
  • Loading branch information
Jannik Stehle committed Jul 19, 2024
1 parent 11ee452 commit e165045
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-dav-id-based-delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Deleting resources via their id

We fixed a bug where deleting resources by using their id via the `/dav/spaces/` endpoint would not work.

https://github.com/cs3org/reva/pull/4771
https://github.com/owncloud/ocis/issues/9619
4 changes: 2 additions & 2 deletions internal/http/services/owncloud/ocdav/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ func (s *svc) handleSpacesDelete(w http.ResponseWriter, r *http.Request, spaceID

// do not allow deleting spaces via dav endpoint - use graph endpoint instead
// we get a relative reference coming from the space root
// so if the path is "empty" we a referencing the space
if ref.GetPath() == "." {
// so if the path is "empty" and no opaque id is present, we are referencing the space
if ref.GetPath() == "." && ref.GetResourceId().GetOpaqueId() == "" {
return http.StatusMethodNotAllowed, errors.New("deleting spaces via dav is not allowed")
}

Expand Down

0 comments on commit e165045

Please sign in to comment.