aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/cmdline.py
diff options
context:
space:
mode:
authorisrael <israel@ubuntu.(none)>2012-12-30 01:41:58 -0800
committerisrael <israel@ubuntu.(none)>2012-12-30 01:41:58 -0800
commit440a9f6bda8d645945e8c056a5e869c712dd2d69 (patch)
tree60a92d02b45daf421a0329e4d404652b8f6b3baa /libmproxy/cmdline.py
parent935505bc4f3c98214ad89884feb7f752d6c87490 (diff)
downloadmitmproxy-440a9f6bda8d645945e8c056a5e869c712dd2d69.tar.gz
mitmproxy-440a9f6bda8d645945e8c056a5e869c712dd2d69.tar.bz2
mitmproxy-440a9f6bda8d645945e8c056a5e869c712dd2d69.zip
adding some simple authetication code to limit proxy access
Diffstat (limited to 'libmproxy/cmdline.py')
-rw-r--r--libmproxy/cmdline.py48
1 files changed, 47 insertions, 1 deletions
diff --git a/libmproxy/cmdline.py b/libmproxy/cmdline.py
index 279c3cb4..db1ebf0d 100644
--- a/libmproxy/cmdline.py
+++ b/libmproxy/cmdline.py
@@ -15,7 +15,7 @@
import proxy
import re, filt
-
+import argparse
class ParseException(Exception): pass
class OptionException(Exception): pass
@@ -334,4 +334,50 @@ def common_options(parser):
help="Header set pattern."
)
+
+ group = parser.add_argument_group(
+ "Proxy Authentication",
+ """
+ Specification of which users are allowed to access the proxy and the method used for authenticating them.
+ If authscheme is specified, one must specify a list of authorized users and their passwords.
+ In case that authscheme is not specified, or set to None, any list of authorized users will be ignored.
+ """.strip()
+ )
+
+ group.add_argument(
+ "--authscheme", type=str,
+ action="store", dest="authscheme", default=None, choices=["none", "basic"],
+ help="""
+ Specify the scheme used by the proxy to identify users.
+ If not none, requires the specification of a list of authorized users.
+ This option is ignored if the proxy is in transparent or reverse mode.
+ """.strip()
+
+ )
+
+ user_specification_group = group.add_mutually_exclusive_group()
+
+
+ user_specification_group.add_argument(
+ "--nonanonymous",
+ action="store_true", dest="auth_nonanonymous",
+ help="Allow access to any user as long as a username is specified. Ignores the provided password."
+ )
+
+ user_specification_group.add_argument(
+ "--singleuser",
+ action="store", dest="auth_singleuser", type=str,
+ help="Allows access to a single user as specified by the option value. Specify a username and password in the form username:password."
+ )
+
+ user_specification_group.add_argument(
+ "--htpasswd",
+ action="store", dest="auth_htpasswd", type=argparse.FileType('r'),
+ help="Allow access to users specified in an Apache htpasswd file."
+ )
+
+
+
+
+
proxy.certificate_option_group(parser)