Skip to content

Commit

Permalink
Allow listing the trashbin (#1091)
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic authored Aug 13, 2020
1 parent f325194 commit 1b82c12
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
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

0 comments on commit 1b82c12

Please sign in to comment.