mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 02:24:18 +00:00
make AuthAction generic
This commit is contained in:
parent
e402e3b862
commit
390f2a46c9
@ -33,6 +33,7 @@ class NullProxyAuth():
|
|||||||
class BasicProxyAuth(NullProxyAuth):
|
class BasicProxyAuth(NullProxyAuth):
|
||||||
CHALLENGE_HEADER = 'Proxy-Authenticate'
|
CHALLENGE_HEADER = 'Proxy-Authenticate'
|
||||||
AUTH_HEADER = 'Proxy-Authorization'
|
AUTH_HEADER = 'Proxy-Authorization'
|
||||||
|
|
||||||
def __init__(self, password_manager, realm):
|
def __init__(self, password_manager, realm):
|
||||||
NullProxyAuth.__init__(self, password_manager)
|
NullProxyAuth.__init__(self, password_manager)
|
||||||
self.realm = realm
|
self.realm = realm
|
||||||
@ -125,11 +126,10 @@ class AuthAction(Action):
|
|||||||
"""
|
"""
|
||||||
def __call__(self, parser, namespace, values, option_string=None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
passman = self.getPasswordManager(values)
|
passman = self.getPasswordManager(values)
|
||||||
if passman:
|
if not passman:
|
||||||
|
raise ArgumentTypeError("Error creating password manager for proxy authentication.")
|
||||||
authenticator = BasicProxyAuth(passman, "mitmproxy")
|
authenticator = BasicProxyAuth(passman, "mitmproxy")
|
||||||
else:
|
setattr(namespace, self.dest, authenticator)
|
||||||
authenticator = NullProxyAuth(None)
|
|
||||||
setattr(namespace, "authenticator", authenticator)
|
|
||||||
|
|
||||||
def getPasswordManager(self, s):
|
def getPasswordManager(self, s):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user