[server] Allow disabling WebDAV

This commit is contained in:
Abhishek Shroff
2025-05-27 23:45:38 +05:30
parent 0efeb08a37
commit cb7ebcbf7a
3 changed files with 20 additions and 11 deletions
+3 -1
View File
@@ -15,7 +15,9 @@ server:
port: 2448
webappsrc: web
publinkpath: /pub
webdavpath: /webdav
webdav:
enabled: true
path: /webdav
cors:
enabled: false
origins:
+4 -2
View File
@@ -49,7 +49,9 @@ func SetupCommand() *cobra.Command {
}
engine := createEngine()
webdav.SetupHandler(engine.Group(Cfg.WebDAVPath))
if Cfg.WebDAV.Enabled {
webdav.SetupHandler(engine.Group(Cfg.WebDAV.Path))
}
apiv1.Setup(engine.Group("/api/v1"))
publink.Setup(engine.Group(Cfg.PublinkPath))
@@ -81,7 +83,7 @@ func setupWebApp(r gin.IRoutes, webAppSrcDir string) {
path := c.Request.URL.Path
if c.Request.Method == "GET" &&
!strings.HasPrefix(path, "/api") &&
!strings.HasPrefix(path, Cfg.WebDAVPath) &&
!strings.HasPrefix(path, Cfg.WebDAV.Path) &&
!strings.HasPrefix(path, Cfg.PublinkPath) {
c.Writer.Header().Set("Cross-Origin-Embedder-Policy", "credentialless")
c.Writer.Header().Set("Cross-Origin-Opener-Policy", "same-origin")
+13 -8
View File
@@ -1,14 +1,19 @@
package serve
type Config struct {
Host string `koanf:"host"`
Port int `koanf:"port"`
WebAppSrc string `koanf:"webappsrc"`
PublinkPath string `koanf:"publinkpath"`
WebDAVPath string `koanf:"webdavpath"`
CORS CORSConfig `koanf:"cors"`
Debug bool `koanf:"debug"`
LogBody bool `koanf:"logbody"`
Host string `koanf:"host"`
Port int `koanf:"port"`
WebAppSrc string `koanf:"webappsrc"`
PublinkPath string `koanf:"publinkpath"`
WebDAV WebDAVConfig `koanf:"webdav"`
CORS CORSConfig `koanf:"cors"`
Debug bool `koanf:"debug"`
LogBody bool `koanf:"logbody"`
}
type WebDAVConfig struct {
Enabled bool `koanf:"enabled"`
Path string `koanf:"path"`
}
type CORSConfig struct {