From bcb6d1cf933fabacf1ecb57f987a95ab618b52dc Mon Sep 17 00:00:00 2001 From: Ben Hardill Date: Fri, 11 Jun 2021 14:25:18 +0100 Subject: [PATCH] Fix for basic auth with @ in username --- .../@node-red/nodes/core/network/21-httprequest.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js b/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js index e6c31bfaa..42e403540 100644 --- a/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js +++ b/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js @@ -207,12 +207,18 @@ module.exports = function(RED) { } if (this.credentials) { if (this.authType === "basic") { + var cred = "" if (this.credentials.user) { - opts.username = this.credentials.user; + // opts.username = this.credentials.user; + cred = this.credentials.user } if (this.credentials.password) { - opts.password = this.credentials.password; + // opts.password = this.credentials.password; + cred += ":" + this.credentials.password } + // build own basic auth header + // Workaround for https://github.com/sindresorhus/got/issues/1169 + opts.headers.Authorization = "Basic " + Buffer.from(cred).toString("base64"); } else if (this.authType === "digest") { let digestCreds = this.credentials; let sentCreds = false;