From f5afafc04c3b4f80a4843a2b0519b414107dd784 Mon Sep 17 00:00:00 2001 From: David Christofas Date: Fri, 20 Nov 2020 11:42:32 +0100 Subject: [PATCH] fix trashbin dav api for ocis (#1326) The dav api now expects username instead of userid. Fixes https://github.com/owncloud/ocis/issues/863 --- changelog/unreleased/fix-ocis-trashbin.md | 7 +++++++ internal/http/services/owncloud/ocdav/trashbin.go | 12 ++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 changelog/unreleased/fix-ocis-trashbin.md diff --git a/changelog/unreleased/fix-ocis-trashbin.md b/changelog/unreleased/fix-ocis-trashbin.md new file mode 100644 index 0000000000..62c4791694 --- /dev/null +++ b/changelog/unreleased/fix-ocis-trashbin.md @@ -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 + diff --git a/internal/http/services/owncloud/ocdav/trashbin.go b/internal/http/services/owncloud/ocdav/trashbin.go index 6386d01643..6ffe67fe42 100644 --- a/internal/http/services/owncloud/ocdav/trashbin.go +++ b/internal/http/services/owncloud/ocdav/trashbin.go @@ -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 @@ -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 @@ -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)