diff --git a/authentik/lib/config.py b/authentik/lib/config.py index 0857d0bf4..2df04ceea 100644 --- a/authentik/lib/config.py +++ b/authentik/lib/config.py @@ -93,7 +93,7 @@ class ConfigLoader: if url.scheme == "file": try: with open(url.path, "r", encoding="utf8") as _file: - value = _file.read() + value = _file.read().strip() except OSError as exc: self.log("error", f"Failed to read config value from {url.path}: {exc}") value = url.query diff --git a/internal/config/config.go b/internal/config/config.go index 72cc9f58b..45c7ee1f4 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -135,7 +135,7 @@ func (c *Config) parseScheme(rawVal string) string { if err != nil { return u.RawQuery } - return string(d) + return strings.TrimSpace(string(d)) } return rawVal } diff --git a/internal/debug/debug.go b/internal/debug/debug.go index eefb68c84..9e8055ca4 100644 --- a/internal/debug/debug.go +++ b/internal/debug/debug.go @@ -1,6 +1,7 @@ package debug import ( + "encoding/json" "fmt" "net/http" "net/http/pprof" @@ -23,6 +24,12 @@ func EnableDebugServer() { h.HandleFunc("/debug/pprof/profile", pprof.Profile) h.HandleFunc("/debug/pprof/symbol", pprof.Symbol) h.HandleFunc("/debug/pprof/trace", pprof.Trace) + h.HandleFunc("/debug/dump_config", func(w http.ResponseWriter, r *http.Request) { + enc := json.NewEncoder(w) + enc.SetEscapeHTML(true) + enc.SetIndent("", "\t") + enc.Encode(config.Get()) + }) h.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { _ = h.Walk(func(route *mux.Route, router *mux.Router, ancestors []*mux.Route) error { tpl, err := route.GetPathTemplate()