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

Allow listing the trashbin #1091

Merged
merged 1 commit into from
Aug 13, 2020
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
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-ocdav-trashbin-listing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Allow listing the trashbin

The trashbin endpoint expects the userid, not the username.

https://github.com/cs3org/reva/pull/1091
11 changes: 6 additions & 5 deletions internal/http/services/owncloud/ocdav/trashbin.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ func (h *TrashbinHandler) Handler(s *svc) http.Handler {
return
}

var username string
username, r.URL.Path = router.ShiftPath(r.URL.Path)
var userid string
userid, r.URL.Path = router.ShiftPath(r.URL.Path)

if username == "" {
if userid == "" {
// listing is disabled, no auth will change that
w.WriteHeader(http.StatusMethodNotAllowed)
return
Expand All @@ -74,7 +74,8 @@ func (h *TrashbinHandler) Handler(s *svc) http.Handler {
w.WriteHeader(http.StatusBadRequest)
return
}
if u.Username != username {
if u.Id.OpaqueId != userid {
log.Debug().Str("userid", userid).Interface("user", u).Msg("trying to read another users trash")
// listing other users trash is forbidden, no auth will change that
w.WriteHeader(http.StatusMethodNotAllowed)
return
Expand Down Expand Up @@ -114,7 +115,7 @@ func (h *TrashbinHandler) Handler(s *svc) http.Handler {

// find path in url relative to trash base
trashBase := ctx.Value(ctxKeyBaseURI).(string)
baseURI := path.Join(path.Dir(trashBase), "files", username)
baseURI := path.Join(path.Dir(trashBase), "files", userid)
ctx = context.WithValue(ctx, ctxKeyBaseURI, baseURI)
r = r.WithContext(ctx)

Expand Down