From ff0b0c2fa6c52ef00362aaaef48e9c38dd224496 Mon Sep 17 00:00:00 2001 From: Gianmaria Del Monte Date: Tue, 9 May 2023 14:54:24 +0200 Subject: [PATCH] adapt webdav ocm endpoint according to historical way of contructing webdav url --- internal/http/services/owncloud/ocdav/dav.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/internal/http/services/owncloud/ocdav/dav.go b/internal/http/services/owncloud/ocdav/dav.go index 54589c322c2..7620cd21449 100644 --- a/internal/http/services/owncloud/ocdav/dav.go +++ b/internal/http/services/owncloud/ocdav/dav.go @@ -21,6 +21,7 @@ package ocdav import ( "context" "net/http" + "net/url" "path" "strings" @@ -187,7 +188,18 @@ func (h *DavHandler) Handler(s *svc) http.Handler { return } - token, _ := router.ShiftPath(r.URL.Path) + // OC10 and Nextcloud (OCM 1.0) are using basic auth for carrying the + // shared token. + var token string + username, _, ok := r.BasicAuth() + if ok { + // OCM 1.0 + token = username + r.URL.Path, _ = url.JoinPath("/", token, r.URL.Path) + } else { + token, _ = router.ShiftPath(r.URL.Path) + } + authRes, err := handleOCMAuth(ctx, c, token) switch { case err != nil: