Support multiple API keys (command-line and config) (fixes #2747)

This commit is contained in:
Antony Male
2016-01-29 17:16:01 +00:00
parent 8ff7531f89
commit 5971c00a4f
5 changed files with 18 additions and 10 deletions

View File

@@ -33,9 +33,8 @@ func emitLoginAttempt(success bool, username string) {
}
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 apiKey != "" && r.Header.Get("X-API-Key") == apiKey {
if cfg.IsValidAPIKey(r.Header.Get("X-API-Key")) {
next.ServeHTTP(w, r)
return
}