*: strip leading and trailing whitespace when reading config values from files
also add a debug endpoint that dumps the go parsed config Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
parent
db60427e21
commit
a1be924fa4
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
Reference in New Issue