allow requesting capabilities from password protected links

This commit is contained in:
Florian Schade committed 2022-02-23 18:46:25 +01:00
1 parent d92dc8951a
commit e8702087f3
3 files changed
+63 -3

No files matched your search

+19 -3
View File
@@ -11,8 +11,6 @@ import (
"github.com/owncloud/ocis/proxy/pkg/webdav"
)
const publicFilesEndpoint = "/remote.php/dav/public-files/"
// BasicAuth provides a middleware to check if BasicAuth is provided
func BasicAuth(optionSetters ...Option) func(next http.Handler) http.Handler {
options := newOptions(optionSetters...)
@@ -111,7 +109,25 @@ type basicAuth struct {
func (m basicAuth) isPublicLink(req *http.Request) bool {
login, _, ok := req.BasicAuth()
return ok && login == "public" && strings.HasPrefix(req.URL.Path, publicFilesEndpoint)
if !ok || login != "public" {
return false
}
publicPaths := []string{
"/remote.php/dav/public-files/",
"/ocs/v1.php/cloud/capabilities",
}
isPublic := false
for _, p := range publicPaths {
if strings.HasPrefix(req.URL.Path, p) {
isPublic = true
break
}
}
return isPublic
}
// The token auth endpoint uses basic auth for clients, see https://openid.net/specs/openid-connect-basic-1_0.html#TokenRequest