##// END OF EJS Templates
url: return the matched authentication group name from readauthforuri()...
Steve Borho -
r13372:5bced0d2 default
parent child Browse files
Show More
@@ -88,7 +88,7 b' def readauthforuri(ui, uri):'
88 88 scheme, hostpath = uri.split('://', 1)
89 89 bestlen = 0
90 90 bestauth = None
91 for auth in config.itervalues():
91 for group, auth in config.iteritems():
92 92 prefix = auth.get('prefix')
93 93 if not prefix:
94 94 continue
@@ -100,7 +100,7 b' def readauthforuri(ui, uri):'
100 100 if (prefix == '*' or hostpath.startswith(prefix)) and \
101 101 len(prefix) > bestlen and scheme in schemes:
102 102 bestlen = len(prefix)
103 bestauth = auth
103 bestauth = group, auth
104 104 return bestauth
105 105
106 106 _safe = ('abcdefghijklmnopqrstuvwxyz'
@@ -155,9 +155,11 b' class passwordmgr(urllib2.HTTPPasswordMg'
155 155 return (user, passwd)
156 156
157 157 if not user:
158 auth = self.readauthtoken(authuri)
159 if auth:
158 res = readauthforuri(self.ui, authuri)
159 if res:
160 group, auth = res
160 161 user, passwd = auth.get('username'), auth.get('password')
162 self.ui.debug("using auth.%s.* for authentication\n" % group)
161 163 if not user or not passwd:
162 164 if not self.ui.interactive():
163 165 raise util.Abort(_('http authorization required'))
@@ -180,9 +182,6 b' class passwordmgr(urllib2.HTTPPasswordMg'
180 182 msg = _('http auth: user %s, password %s\n')
181 183 self.ui.debug(msg % (user, passwd and '*' * len(passwd) or 'not set'))
182 184
183 def readauthtoken(self, uri):
184 return readauthforuri(self.ui, uri)
185
186 185 class proxyhandler(urllib2.ProxyHandler):
187 186 def __init__(self, ui):
188 187 proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy')
@@ -624,7 +623,13 b' if has_https:'
624 623 return keepalive.KeepAliveHandler._start_transaction(self, h, req)
625 624
626 625 def https_open(self, req):
627 self.auth = self.pwmgr.readauthtoken(req.get_full_url())
626 res = readauthforuri(self.ui, req.get_full_url())
627 if res:
628 group, auth = res
629 self.auth = auth
630 self.ui.debug("using auth.%s.* for authentication\n" % group)
631 else:
632 self.auth = None
628 633 return self.do_open(self._makeconnection, req)
629 634
630 635 def _makeconnection(self, host, port=None, *args, **kwargs):
General Comments 0
You need to be logged in to leave comments. Login now