1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add support for user/pass in URL

This commit is contained in:
Ben Hardill 2021-06-11 14:48:41 +01:00
parent 553bec1a1f
commit 919aee64f9
No known key found for this signature in database
GPG Key ID: 74DD076979ABB1E7

View File

@ -207,17 +207,22 @@ module.exports = function(RED) {
}
if (this.credentials) {
if (this.authType === "basic") {
// Workaround for https://github.com/sindresorhus/got/issues/1169
var cred = ""
var parsedURL = new URL(url)
if (this.credentials.user) {
// opts.username = this.credentials.user;
cred = this.credentials.user
} else if (parsedURL.username) {
cred = parsedURL.username
}
if (this.credentials.password) {
// opts.password = this.credentials.password;
cred += ":" + this.credentials.password
} else if (parsedURL.password) {
cred += ":" + parsedURL.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;