Skip to content

Commit

Permalink
adapt webdav ocm endpoint according to historical way of contructing …
Browse files Browse the repository at this point in the history
…webdav url
  • Loading branch information
gmgigi96 committed May 10, 2023
1 parent 1028891 commit ff0b0c2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion internal/http/services/owncloud/ocdav/dav.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package ocdav
import (
"context"
"net/http"
"net/url"
"path"
"strings"

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit ff0b0c2

Please sign in to comment.