From bd400466023925cce61c28dfb6f1379e2e0ad72f Mon Sep 17 00:00:00 2001 From: Sulka Haro Date: Fri, 30 Dec 2022 22:15:48 +0200 Subject: [PATCH] Change the SHA1 validation to be case insensitive (#7780) Co-authored-by: Ben West --- lib/server/enclave.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/server/enclave.js b/lib/server/enclave.js index 3e62a04a0c6..03dc8facf96 100644 --- a/lib/server/enclave.js +++ b/lib/server/enclave.js @@ -32,7 +32,7 @@ const init = function init () { function genHash(data, algorihtm) { const hash = crypto.createHash(algorihtm); data = hash.update(data, 'utf-8'); - return data.digest('hex'); + return data.digest('hex').toLowerCase(); } enclave.setApiKey = function setApiKey (keyValue) { @@ -48,7 +48,7 @@ const init = function init () { } enclave.isApiKey = function isApiKey (keyValue) { - return keyValue == secrets[apiKeySHA1] || keyValue == secrets[apiKeySHA512]; + return keyValue.toLowerCase() == secrets[apiKeySHA1] || keyValue == secrets[apiKeySHA512]; } enclave.setJWTKey = function setJWTKey (keyValue) { @@ -72,7 +72,7 @@ const init = function init () { var shasum = crypto.createHash('sha1'); shasum.update(secrets[apiKeySHA1]); shasum.update(id); - return shasum.digest('hex'); + return shasum.digest('hex').toLowerCase(); } return enclave;