Skip to content

Commit

Permalink
Fix git DataSource clone authentication
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alehaa authored and jeremystretch committed Aug 15, 2023
1 parent c46536f commit 16e2283
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions netbox/core/data_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 16e2283

Please sign in to comment.