Skip to content

Commit

Permalink
Attempt to support both OCM 1.0 and 1.1 when accessing remote shares
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern committed May 23, 2024
1 parent d22f762 commit e6ab385
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/ocm/storage/received/ocm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e6ab385

Please sign in to comment.