From b95869d0007d18357efa7040b7d7e457584f3020 Mon Sep 17 00:00:00 2001 From: Sulka Haro Date: Sat, 17 Dec 2022 13:18:55 +0200 Subject: [PATCH] Change the SHA1 validation to be case insensitive --- 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;