mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-10-25 07:39:31 -04:00
allow requesting capabilities from password protected links
This commit is contained in:
1 parent
d92dc8951a
commit
e8702087f3
3 files changed
+63
-3
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user