Option -gui-address should accept scheme prefixes (fixes #2371)

This commit is contained in:
Jakob Borg
2015-10-12 22:27:57 +09:00
parent 240e7b0835
commit 953a67bc3a
5 changed files with 123 additions and 73 deletions

View File

@@ -25,8 +25,9 @@ var (
)
func basicAuthAndSessionMiddleware(cookieName string, cfg config.GUIConfiguration, next http.Handler) http.Handler {
apiKey := cfg.APIKey()
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if cfg.APIKey != "" && r.Header.Get("X-API-Key") == cfg.APIKey {
if apiKey != "" && r.Header.Get("X-API-Key") == apiKey {
next.ServeHTTP(w, r)
return
}