Search code examples
gitauthenticationnginxtortoisegitgogs

http auth does not work with TortoiseGit


Every time I try to clone any repo with TortoiseGit from our remote gogs repo I get 401 (Unauthorized).

Using http://user:[email protected]/user/repo.git as checkout url does not work either.
ssh is not an option. Everything works with http auth disabled.

simplified nginx config:

server {
        listen 80;
        listen [::]:80;
        server_name ex.ample.com;
                location / {
                        auth_basic "Restricted Content";
                        auth_basic_user_file /var/www/gogs/.htpasswd;
                        proxy_pass http://localhost:3000/;
                }
}

So my question would be: how do I configure TortoiseGit to send valid http auth?

Edit: seems to only affect private repos, public repos are accessible.
Edit2: pushing to public repos is not possible behind http auth aswell.

Solution: https with reverse proxy is behaving oddly, so repo url and push url have to be used with plain http. Probably some nginx tweeking needed here.


Solution

  • Git is a "stupid content tracker". It just tracks content and does not provide or require any authentication or authorization.

    If you want any authentication and/or authorization you need to put it on top somehow.

    If you use gogs, you need to configure authentication there or pass the username from your nginx proxy (cf. https://github.com/gogits/gogs/issues/165, https://github.com/gogits/gogs/issues/2170, https://github.com/gogits/gogs/pull/3785, ...).

    For other approches to server Git using http see How to serve GIT through HTTP via NGINX with user/password? or http://gitolite.com/gitolite/http/.


    Old answer:

    With basic authentication there can only be one authentication not two or even more.

    Only exception is proxy authentication (http status code 407 which is done using a different header).

    You could try forward your basic auth credentials to your other server by proxying the credentials https://serverfault.com/q/511206/237109 or try to provide static credentials in your nginx config.