fix(auth): fix HTTP Basic auth for NOPASS indexes (#8442)

This commit is contained in:
Kevin James 2021-01-28 21:28:52 -08:00 committed by GitHub
parent 4eaa81ac56
commit 9e09363305
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -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}`

View file

@ -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;