From 8fd6eddc1684f5e990608465f8f013a863187ef9 Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Wed, 14 Oct 2020 21:45:45 -0400 Subject: [PATCH] Make sure that the SHA512 hash is lowercase --- security/handler.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/security/handler.go b/security/handler.go index 251a9cef..c63f57a8 100644 --- a/security/handler.go +++ b/security/handler.go @@ -2,12 +2,13 @@ package security import ( "net/http" + "strings" ) func Handler(handler http.HandlerFunc, security *Config) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { usernameEntered, passwordEntered, ok := r.BasicAuth() - if !ok || usernameEntered != security.Basic.Username || Sha512(passwordEntered) != security.Basic.PasswordSha512Hash { + if !ok || usernameEntered != security.Basic.Username || Sha512(passwordEntered) != strings.ToLower(security.Basic.PasswordSha512Hash) { w.Header().Set("WWW-Authenticate", "Basic") w.WriteHeader(http.StatusUnauthorized) _, _ = w.Write([]byte("Unauthorized"))