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:
parent
553bec1a1f
commit
919aee64f9
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user