set request auth if both username and password are non empty

BitBucket servers don't accept a username with an empty password, so a
secret with no http auth creds will result in a 401, since we
fall back to "git" for the username and used to set basic auth with that
username without a password.

Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
This commit is contained in:
Sanskar Jaiswal 2022-06-23 14:44:12 +05:30
parent 7c07b7a03f
commit 7a708ac6d2
1 changed files with 1 additions and 1 deletions

View File

@ -279,7 +279,7 @@ func createClientRequest(targetURL string, action git2go.SmartServiceAction,
// Apply authentication and TLS settings to the HTTP transport.
if authOpts != nil {
if len(authOpts.Username) > 0 {
if authOpts.Username != "" && authOpts.Password != "" {
req.SetBasicAuth(authOpts.Username, authOpts.Password)
}
if len(authOpts.CAFile) > 0 {