Преглед изворни кода

Fix git DataSource clone authentication

Anonymous git clones (in GitLab) require the username and password not
to be set in order to successfully clone. This patch will define clone
args only, if the username passed is not empty.
Alexander Haase пре 2 година
родитељ
комит
16e2283d19
1 измењених фајлова са 7 додато и 6 уклоњено
  1. 7 6
      netbox/core/data_backends.py

+ 7 - 6
netbox/core/data_backends.py

@@ -103,12 +103,13 @@ class GitBackend(DataBackend):
         }
         }
 
 
         if self.url_scheme in ('http', 'https'):
         if self.url_scheme in ('http', 'https'):
-            clone_args.update(
-                {
-                    "username": self.params.get('username'),
-                    "password": self.params.get('password'),
-                }
-            )
+            if self.params.get('username'):
+                clone_args.update(
+                    {
+                        "username": self.params.get('username'),
+                        "password": self.params.get('password'),
+                    }
+                )
 
 
         if settings.HTTP_PROXIES and self.url_scheme in ('http', 'https'):
         if settings.HTTP_PROXIES and self.url_scheme in ('http', 'https'):
             if proxy := settings.HTTP_PROXIES.get(self.url_scheme):
             if proxy := settings.HTTP_PROXIES.get(self.url_scheme):