From 16e2283d192c9726c5010144df576baa3b16ccd7 Mon Sep 17 00:00:00 2001 From: Alexander Haase Date: Thu, 3 Aug 2023 12:57:01 +0200 Subject: [PATCH] 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. --- netbox/core/data_backends.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/netbox/core/data_backends.py b/netbox/core/data_backends.py index 43e6f4e799f..8863e1aeffd 100644 --- a/netbox/core/data_backends.py +++ b/netbox/core/data_backends.py @@ -103,12 +103,13 @@ def fetch(self): } 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 proxy := settings.HTTP_PROXIES.get(self.url_scheme):