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