##// END OF EJS Templates
http: pass user to readauthforuri() (fix 4a43e23b8c55)...
Patrick Mezard -
r15025:0593e8f8 stable
parent child Browse files
Show More
@@ -58,7 +58,7 b' class httpsendfile(object):'
58 58 return self._len
59 59
60 60 # moved here from url.py to avoid a cycle
61 def readauthforuri(ui, uri):
61 def readauthforuri(ui, uri, user):
62 62 # Read configuration
63 63 config = dict()
64 64 for key, val in ui.configitems('auth'):
@@ -72,10 +72,6 b' def readauthforuri(ui, uri):'
72 72 gdict[setting] = val
73 73
74 74 # Find the best match
75 uri = util.url(uri)
76 user = uri.user
77 uri.user = uri.password = None
78 uri = str(uri)
79 75 scheme, hostpath = uri.split('://', 1)
80 76 bestuser = None
81 77 bestlen = 0
@@ -238,7 +234,11 b' class http2handler(urllib2.HTTPHandler, '
238 234 return self.do_open(HTTPConnection, req, False)
239 235
240 236 def https_open(self, req):
241 res = readauthforuri(self.ui, req.get_full_url())
237 # req.get_full_url() does not contain credentials and we may
238 # need them to match the certificates.
239 url = req.get_full_url()
240 user, password = self.pwmgr.find_stored_password(url)
241 res = readauthforuri(self.ui, url, user)
242 242 if res:
243 243 group, auth = res
244 244 self.auth = auth
@@ -26,7 +26,7 b' class passwordmgr(urllib2.HTTPPasswordMg'
26 26 return (user, passwd)
27 27
28 28 if not user or not passwd:
29 res = httpconnectionmod.readauthforuri(self.ui, authuri)
29 res = httpconnectionmod.readauthforuri(self.ui, authuri, user)
30 30 if res:
31 31 group, auth = res
32 32 user, passwd = auth.get('username'), auth.get('password')
@@ -53,6 +53,10 b' class passwordmgr(urllib2.HTTPPasswordMg'
53 53 msg = _('http auth: user %s, password %s\n')
54 54 self.ui.debug(msg % (user, passwd and '*' * len(passwd) or 'not set'))
55 55
56 def find_stored_password(self, authuri):
57 return urllib2.HTTPPasswordMgrWithDefaultRealm.find_user_password(
58 self, None, authuri)
59
56 60 class proxyhandler(urllib2.ProxyHandler):
57 61 def __init__(self, ui):
58 62 proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy')
@@ -342,7 +346,11 b' if has_https:'
342 346 return keepalive.KeepAliveHandler._start_transaction(self, h, req)
343 347
344 348 def https_open(self, req):
345 res = httpconnectionmod.readauthforuri(self.ui, req.get_full_url())
349 # req.get_full_url() does not contain credentials and we may
350 # need them to match the certificates.
351 url = req.get_full_url()
352 user, password = self.pwmgr.find_stored_password(url)
353 res = httpconnectionmod.readauthforuri(self.ui, url, user)
346 354 if res:
347 355 group, auth = res
348 356 self.auth = auth
@@ -37,10 +37,10 b' def test(auth, urls=None):'
37 37 print 'URI:', uri
38 38 try:
39 39 pm = url.passwordmgr(ui)
40 authinfo = util.url(uri).authinfo()[1]
40 u, authinfo = util.url(uri).authinfo()
41 41 if authinfo is not None:
42 42 pm.add_password(*authinfo)
43 print ' ', pm.find_user_password('test', uri)
43 print ' ', pm.find_user_password('test', u)
44 44 except Abort, e:
45 45 print 'abort'
46 46
General Comments 0
You need to be logged in to leave comments. Login now