mirror of
https://codeberg.org/shroff/phylum.git
synced 2026-05-08 13:19:22 -05:00
[server] Allow disabling WebDAV
This commit is contained in:
@@ -15,7 +15,9 @@ server:
|
||||
port: 2448
|
||||
webappsrc: web
|
||||
publinkpath: /pub
|
||||
webdavpath: /webdav
|
||||
webdav:
|
||||
enabled: true
|
||||
path: /webdav
|
||||
cors:
|
||||
enabled: false
|
||||
origins:
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user