Skip to content

Commit

Permalink
(chocolatey#3242) Attempt default credentials for sources
Browse files Browse the repository at this point in the history
When attempting a query to a source that requires credentials, we were
always prompting for credentials. This prevents attempting the default
credentials unless entering an empty password. We should attempt
initially with the default credentials, and only prompt if it's a retry
for credentials.
  • Loading branch information
corbob committed Jul 5, 2023
1 parent d836138 commit fe5898b
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,16 @@ public Task<CredentialResponse> GetAsync(Uri uri, IWebProxy proxy, CredentialReq

if (source == null)
{
this.Log().Debug("Asking user for credentials for '{0}'".FormatWith(uri.OriginalString));
return Task.FromResult(new CredentialResponse(GetUserCredentials(uri, proxy, credentialType)));
ICredentials credential = CredentialCache.DefaultNetworkCredentials;

if (isRetry)
{
this.Log().Debug("This is a retry attempt. Asking user for credentials for '{0}'".FormatWith(uri.OriginalString));
credential = GetUserCredentials(uri, proxy, credentialType);

}

return Task.FromResult(new CredentialResponse(credential));
}
else
{
Expand Down

0 comments on commit fe5898b

Please sign in to comment.