From f6026fdb13e79d720a7db4c67e9b3b54be4b12cb Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 21 Jun 2021 21:21:35 +0200 Subject: [PATCH] root: allow loading local /static files without debug flag Signed-off-by: Jens Langhammer --- authentik/lib/default.yml | 1 + internal/config/config.go | 5 +++-- internal/config/struct.go | 5 +++-- internal/web/web_static.go | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/authentik/lib/default.yml b/authentik/lib/default.yml index 54fc3f989..061e2139d 100644 --- a/authentik/lib/default.yml +++ b/authentik/lib/default.yml @@ -9,6 +9,7 @@ postgresql: web: listen: 0.0.0.0:9000 listen_tls: 0.0.0.0:9443 + load_local_files: false redis: host: localhost diff --git a/internal/config/config.go b/internal/config/config.go index c1811dd5c..db640f8d5 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -16,8 +16,9 @@ func DefaultConfig() { G = Config{ Debug: false, Web: WebConfig{ - Listen: "localhost:9000", - ListenTLS: "localhost:9443", + Listen: "localhost:9000", + ListenTLS: "localhost:9443", + LoadLocalFiles: false, }, Paths: PathsConfig{ Media: "./media", diff --git a/internal/config/struct.go b/internal/config/struct.go index 155e7f702..6b21b5681 100644 --- a/internal/config/struct.go +++ b/internal/config/struct.go @@ -9,8 +9,9 @@ type Config struct { } type WebConfig struct { - Listen string `yaml:"listen"` - ListenTLS string `yaml:"listen_tls"` + Listen string `yaml:"listen"` + ListenTLS string `yaml:"listen_tls"` + LoadLocalFiles bool `yaml:"load_local_files"` } type PathsConfig struct { diff --git a/internal/web/web_static.go b/internal/web/web_static.go index 41452f480..06d30eddd 100644 --- a/internal/web/web_static.go +++ b/internal/web/web_static.go @@ -10,7 +10,7 @@ import ( func (ws *WebServer) configureStatic() { statRouter := ws.lh.NewRoute().Subrouter() - if config.G.Debug { + if config.G.Debug || config.G.Web.LoadLocalFiles { ws.log.Debug("Using local static files") ws.lh.PathPrefix("/static/dist").Handler(http.StripPrefix("/static/dist", http.FileServer(http.Dir("./web/dist")))) ws.lh.PathPrefix("/static/authentik").Handler(http.StripPrefix("/static/authentik", http.FileServer(http.Dir("./web/authentik"))))