From 7a708ac6d2e10d918055ea49ad07dddc10a281d6 Mon Sep 17 00:00:00 2001 From: Sanskar Jaiswal Date: Thu, 23 Jun 2022 14:44:12 +0530 Subject: [PATCH] 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 --- pkg/git/libgit2/managed/http.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/git/libgit2/managed/http.go b/pkg/git/libgit2/managed/http.go index 5fa1f28f2..7ae23db9e 100644 --- a/pkg/git/libgit2/managed/http.go +++ b/pkg/git/libgit2/managed/http.go @@ -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 {