diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2013-01-02 17:35:44 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2013-01-02 17:35:44 +1300 |
commit | 09f664cdeafae1d9923fe5ce2c4ab3acc7757a61 (patch) | |
tree | 0adf9c05514074efa36b8ff69770909a596d3caa /libmproxy/proxy.py | |
parent | 7b3d3dc85e9618f4b16f2c81a37429ebdaf5ebf2 (diff) | |
download | mitmproxy-09f664cdeafae1d9923fe5ce2c4ab3acc7757a61.tar.gz mitmproxy-09f664cdeafae1d9923fe5ce2c4ab3acc7757a61.tar.bz2 mitmproxy-09f664cdeafae1d9923fe5ce2c4ab3acc7757a61.zip |
Refactor proxy auth a bit
- Remove authentication scheme option. We only support basic at the moment -
we'll add the option back when we diversify.
- Add some meta variables to make printout nicer
Diffstat (limited to 'libmproxy/proxy.py')
-rw-r--r-- | libmproxy/proxy.py | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index 9abb9833..22e7ff63 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -544,25 +544,20 @@ def process_proxy_options(parser, options): if not os.path.exists(options.certdir) or not os.path.isdir(options.certdir): parser.error("Dummy cert directory does not exist or is not a directory: %s"%options.certdir) - if options.authscheme and (options.authscheme!='none'): - if not (options.auth_nonanonymous or options.auth_singleuser or options.auth_htpasswd): - parser.error("Proxy authentication scheme is specified, but no allowed user list is given.") - if options.auth_singleuser and len(options.auth_singleuser.split(':'))!=2: - parser.error("Authorized user is not given in correct format username:password") - if options.auth_nonanonymous: - password_manager = authentication.PermissivePasswordManager() - elif options.auth_singleuser: + if (options.auth_nonanonymous or options.auth_singleuser or options.auth_htpasswd): + if options.auth_singleuser: + if len(options.auth_singleuser.split(':')) != 2: + parser.error("Please specify user in the format username:password") username, password = options.auth_singleuser.split(':') password_manager = authentication.SingleUserPasswordManager(username, password) + elif options.auth_nonanonymous: + password_manager = authentication.PermissivePasswordManager() elif options.auth_htpasswd: password_manager = authentication.HtpasswdPasswordManager(options.auth_htpasswd) - # in the meanwhile, basic auth is the only true authentication scheme we support - # so just use it authenticator = authentication.BasicProxyAuth(password_manager, "mitmproxy") else: authenticator = authentication.NullProxyAuth(None) - return ProxyConfig( certfile = options.cert, cacert = cacert, |