From e6ab3850473989de2eb8afdb287010457e918caf Mon Sep 17 00:00:00 2001 From: Giuseppe Lo Presti Date: Thu, 23 May 2024 16:17:30 +0200 Subject: [PATCH] Attempt to support both OCM 1.0 and 1.1 when accessing remote shares --- pkg/ocm/storage/received/ocm.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/ocm/storage/received/ocm.go b/pkg/ocm/storage/received/ocm.go index 89e73ef29b0..24657342cf8 100644 --- a/pkg/ocm/storage/received/ocm.go +++ b/pkg/ocm/storage/received/ocm.go @@ -155,8 +155,16 @@ func (d *driver) webdavClient(ctx context.Context, ref *provider.Reference) (*go return nil, nil, "", err } - // use the secret as bearer authentication according to OCM v1.1+ - c := gowebdav.NewClient(endpoint, "", "") + // inject the secret as 'username' for OCM v1.0 basic auhentication: + // this is deprecated but still used by Nextcloud v28 (latest stable) at least. + parsedURL, err := url.Parse(endpoint) + if err != nil { + return nil, nil, "", err + } + parsedURL.User = url.UserPassword(secret, "") + + // and use it also as bearer authentication according to OCM v1.1+ + c := gowebdav.NewClient(parsedURL.String(), "", "") c.SetHeader("Authorization", "Bearer "+secret) log := appctx.GetLogger(ctx)