http default implementation doesn't support authentication

Bug #909037 reported by Jelmer Vernooij
32
This bug affects 6 people
Affects Status Importance Assigned to Milestone
Dulwich
Fix Released
Medium
Unassigned
hg-git
New
Undecided
Unassigned

Bug Description

The default dulwich http client doesn't support authentication at the moment.

HttpGitClient._perform needs to be extended to enable authentication and pass down credentials.

Tags: http
Revision history for this message
Thomas Ibel (tibel) wrote :
Revision history for this message
diryboy (lancevdance) wrote :

I was not able to push to codeplex git repos using hg-git

Revision history for this message
Dov Feldstern (dovdevel) wrote :

This issue comes up quite often on the hg-git mailing list. Recently, a solution was posted there [1] which monkey-patches dulwich to provide support for basic authentication. However, the hg-git maintainer prefers (rightly so, as far as I understand) that the support be added in dulwich itself. This is a first attempt at porting parts of that patch into dulwich in a way that I hope makes sense.

This still requires some work -- passing in the 'authinfo' as a dictionary probably doesn't make much sense. But I hope this can serve as a basis for finally getting this fixed.

I will also post a message about this to the hg-git mailing list, along with the matching patch that needs to be applied in hg-git to make use of this.

[1] https://groups.google.com/forum/#!topic/hg-git/9clPr1wdtiw

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Thanks for the patch. I agree it's a bad idea to monkey patch in hg-git.

That said, dulwich is also the wrong place for this. Rather than supporting every possible form of authentication directly in Dulwich and simply passing that data on to urllib2, it would be better to allow passing in the urllib2 requests.

Revision history for this message
Dov Feldstern (dovdevel) wrote :

Here's a patch using urllib2's "handlers" mechanism. Now dulwich no longer needs to deal with the details of this or that authentication method -- it is up to the client (hg-git, in our case) to set up the appropriate handler(s).

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Thanks for the patch; handlers do seem like a very good fit here. Is there any way we can use handlers without affecting the global state? Dulwich might be loaded into another application that also uses urllib2, and so modifying the opener may have unwanted side effects.

Revision history for this message
Dov Feldstern (dovdevel) wrote :

Yes, it's possible to use the opener directly for opening a url, see attached (to be added *in addition* to the previous patch).

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Thanks, applied with some additional changes. You can now just provide a custom opener to HttpGitClient, and HttpGitClient._perform has been removed.

Changed in dulwich:
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.