From 9e093633054540b23ced6b15934906eee87a985d Mon Sep 17 00:00:00 2001 From: Kevin James <KevinJames@thekev.in> Date: Thu, 28 Jan 2021 21:28:52 -0800 Subject: [PATCH] fix(auth): fix HTTP Basic auth for NOPASS indexes (#8442) --- lib/util/http/auth.ts | 2 +- lib/util/http/host-rules.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/util/http/auth.ts b/lib/util/http/auth.ts index e6ac53f26c..6e98d5f582 100644 --- a/lib/util/http/auth.ts +++ b/lib/util/http/auth.ts @@ -39,7 +39,7 @@ export function applyAuthorization(inOptions: GotOptions): GotOptions { options.headers.authorization = `Bearer ${options.token}`; } delete options.token; - } else if (options.password) { + } else if (options.password !== undefined) { // Otherwise got will add username and password to url and header const auth = Buffer.from( `${options.username || ''}:${options.password}` diff --git a/lib/util/http/host-rules.ts b/lib/util/http/host-rules.ts index b6690fedbe..f83f599b1c 100644 --- a/lib/util/http/host-rules.ts +++ b/lib/util/http/host-rules.ts @@ -15,7 +15,7 @@ export function applyHostRules(url: string, inOptions: GotOptions): GotOptions { const { username, password, token, enabled } = foundRules; if (options.headers?.authorization || options.password || options.token) { logger.trace({ url }, `Authorization already set`); - } else if (password) { + } else if (password !== undefined) { logger.trace({ url }, `Applying Basic authentication`); options.username = username; options.password = password; -- GitLab