aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/proxy.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-12-31 09:15:56 +1300
committerAldo Cortesi <aldo@nullcube.com>2012-12-31 09:15:56 +1300
commit018c229ae40d93f0f0987a37a33256db57cdc62c (patch)
tree6a098c71f3af7c8a52b58c342522723ef89ad3c1 /libmproxy/proxy.py
parentcfab27232127437cca8ac3699065db653da97dba (diff)
downloadmitmproxy-018c229ae40d93f0f0987a37a33256db57cdc62c.tar.gz
mitmproxy-018c229ae40d93f0f0987a37a33256db57cdc62c.tar.bz2
mitmproxy-018c229ae40d93f0f0987a37a33256db57cdc62c.zip
Start solidifying proxy authentication
- Add a unit test file - Remove some extraneous methods - Change the auth API to make the authenticate method take a header object.
Diffstat (limited to 'libmproxy/proxy.py')
-rw-r--r--libmproxy/proxy.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py
index b1ce310c..2c62a880 100644
--- a/libmproxy/proxy.py
+++ b/libmproxy/proxy.py
@@ -356,8 +356,12 @@ class ProxyHandler(tcp.BaseHandler):
headers = http.read_headers(self.rfile)
if headers is None:
raise ProxyError(400, "Invalid headers")
- if authenticate and self.config.authenticator and not self.config.authenticator.authenticate(headers.get('Proxy-Authorization', [])):
- raise ProxyError(407, "Proxy Authentication Required", self.config.authenticator.auth_challenge_headers())
+ if authenticate and self.config.authenticator and not self.config.authenticator.authenticate(headers):
+ raise ProxyError(
+ 407,
+ "Proxy Authentication Required",
+ self.config.authenticator.auth_challenge_headers()
+ )
return headers
def send_response(self, response):