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

fix trashbin dav api for ocis #1326

Merged
merged 1 commit into from
Nov 20, 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
7 changes: 7 additions & 0 deletions changelog/unreleased/fix-ocis-trashbin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: fix dav api for trashbin

The api was comparing the requested username to the userid.


https://github.com/owncloud/ocis/issues/863

12 changes: 6 additions & 6 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 userid string
userid, r.URL.Path = router.ShiftPath(r.URL.Path)
var username string
username, r.URL.Path = router.ShiftPath(r.URL.Path)

if userid == "" {
if username == "" {
// listing is disabled, no auth will change that
w.WriteHeader(http.StatusMethodNotAllowed)
return
Expand All @@ -74,8 +74,8 @@ func (h *TrashbinHandler) Handler(s *svc) http.Handler {
w.WriteHeader(http.StatusBadRequest)
return
}
if u.Id.OpaqueId != userid {
log.Debug().Str("userid", userid).Interface("user", u).Msg("trying to read another users trash")
if u.Username != username {
log.Debug().Str("username", username).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 All @@ -98,7 +98,7 @@ func (h *TrashbinHandler) Handler(s *svc) http.Handler {
if key != "" && r.Method == "MOVE" {
// find path in url relative to trash base
trashBase := ctx.Value(ctxKeyBaseURI).(string)
baseURI := path.Join(path.Dir(trashBase), "files", userid)
baseURI := path.Join(path.Dir(trashBase), "files", username)
ctx = context.WithValue(ctx, ctxKeyBaseURI, baseURI)
r = r.WithContext(ctx)

Expand Down