[Backport 7.x] ApiKey should take precedence over basic auth (#1117)

* ApiKey should take precedence over basic auth

* Updated docs

* Updated test

Co-authored-by: Tomas Della Vedova <delvedor@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2020-03-13 13:41:57 +01:00
committed by GitHub
parent ca23e0b23a
commit a9a905409e
4 changed files with 103 additions and 7 deletions

View File

@ -42,13 +42,13 @@ class BaseConnectionPool {
opts = this.urlToHost(opts)
}
if (opts.url.username !== '' && opts.url.password !== '') {
if (this.auth !== null) {
opts.auth = this.auth
} else if (opts.url.username !== '' && opts.url.password !== '') {
opts.auth = {
username: decodeURIComponent(opts.url.username),
password: decodeURIComponent(opts.url.password)
}
} else if (this.auth !== null) {
opts.auth = this.auth
}
if (opts.ssl == null) opts.ssl = this._ssl