Skip to content

HTTPS authentication failure with Python 3

Hi,

I have an issue which prevents me from authenticating on my company's internal Gitlab repositories. I was able to track it down to hg-git using b'username':b'password' as the credentials instead of username:password.

I've added traces in git_handler.py which show that in my case it gets the credentials from line 1918:

username, password = pwmgr.find_stored_password(str_uri)

I was able to work around the issue by changing lines 1913-1918 to the following (which should work in all cases on Python 3):

            if self._http_auth_realm:
                # since we've tried an unauthenticated request, and
                # obtain a realm, we can do a "full" search, including
                # a prompt
                username, password = pwmgr.find_user_password(
                    self._http_auth_realm, str_uri,
                )
            elif auth is not None:
                username, password = auth
            else:
                username, password = pwmgr.find_stored_password(str_uri)
            if isinstance(username, bytes): username = username.decode('utf-8')
            if isinstance(password, bytes): password = password.decode('utf-8')

Versions:

  • dulwich 0.20.21
  • hg-git 0.10.1
  • mercurial 5.8
  • mercurial-keyring 1.4.1
  • Python 3.7.3
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information