Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust permissions for deleting spaces #2828

Merged
merged 3 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/deleteSpacePermissions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Check permissions when deleting spaces

Do not allow viewers and editors to delete a space (you need to be manager)
Block deleting a space via dav service (should use graph to avoid accidental deletes)

https://github.com/cs3org/reva/pull/2827
9 changes: 9 additions & 0 deletions internal/http/services/owncloud/ocdav/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,14 @@ func (s *svc) handleSpacesDelete(w http.ResponseWriter, r *http.Request, spaceID
return
}

// 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() == "." {
sublog.Info().Msg("deleting spaces via dav is not allowed")
w.WriteHeader(http.StatusBadRequest)
return
}

s.handleDelete(ctx, w, r, ref, sublog)
}
5 changes: 5 additions & 0 deletions pkg/storage/utils/decomposedfs/spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,11 @@ func (fs *Decomposedfs) DeleteStorageSpace(ctx context.Context, req *provider.De
return err
}

// only managers are allowed to disable or purge a drive
if err := fs.checkManagerPermission(ctx, n); err != nil {
return errtypes.PermissionDenied(fmt.Sprintf("user is not allowed to delete spaces %s", n.ID))
}

if purge {
if !n.IsDisabled() {
return errtypes.NewErrtypeFromStatus(status.NewInvalidArg(ctx, "can't purge enabled space"))
Expand Down