From 390f2a46c920ee332d758d6c46999b5147e0b30b Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Sun, 8 Dec 2013 01:37:45 +0100 Subject: [PATCH] make AuthAction generic --- netlib/http_auth.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/netlib/http_auth.py b/netlib/http_auth.py index 6c91c7c52..948d503a4 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): """