aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/http_auth.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2013-12-08 01:37:45 +0100
committerMaximilian Hils <git@maximilianhils.com>2013-12-08 01:37:45 +0100
commit390f2a46c920ee332d758d6c46999b5147e0b30b (patch)
tree9fe0be978c2389279e2aaec7929d225bea40bb93 /netlib/http_auth.py
parente402e3b862312ca4f7bd7dd633db3654143c3380 (diff)
downloadmitmproxy-390f2a46c920ee332d758d6c46999b5147e0b30b.tar.gz
mitmproxy-390f2a46c920ee332d758d6c46999b5147e0b30b.tar.bz2
mitmproxy-390f2a46c920ee332d758d6c46999b5147e0b30b.zip
make AuthAction generic
Diffstat (limited to 'netlib/http_auth.py')
-rw-r--r--netlib/http_auth.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/netlib/http_auth.py b/netlib/http_auth.py
index 6c91c7c5..948d503a 100644
--- a/netlib/http_auth.py
+++ b/netlib/http_auth.py
@@ -33,6 +33,7 @@ class NullProxyAuth():
class BasicProxyAuth(NullProxyAuth):
CHALLENGE_HEADER = 'Proxy-Authenticate'
AUTH_HEADER = 'Proxy-Authorization'
+
def __init__(self, password_manager, realm):
NullProxyAuth.__init__(self, password_manager)
self.realm = realm
@@ -125,11 +126,10 @@ class AuthAction(Action):
"""
def __call__(self, parser, namespace, values, option_string=None):
passman = self.getPasswordManager(values)
- if passman:
- authenticator = BasicProxyAuth(passman, "mitmproxy")
- else:
- authenticator = NullProxyAuth(None)
- setattr(namespace, "authenticator", authenticator)
+ if not passman:
+ raise ArgumentTypeError("Error creating password manager for proxy authentication.")
+ authenticator = BasicProxyAuth(passman, "mitmproxy")
+ setattr(namespace, self.dest, authenticator)
def getPasswordManager(self, s):
"""