diff options
author | Guillem Anguera <ganguera@gmail.com> | 2016-02-12 23:30:42 +0100 |
---|---|---|
committer | Guillem Anguera <ganguera@gmail.com> | 2016-02-12 23:30:42 +0100 |
commit | 195ea8e15ac3822c1524ee4742ec42ca76638876 (patch) | |
tree | 79b6c680b851128e5509b0910cd5bf89e4f290c7 /libmproxy | |
parent | 53065234466918daf36ebe6d3b10d264979fc8ae (diff) | |
download | mitmproxy-195ea8e15ac3822c1524ee4742ec42ca76638876.tar.gz mitmproxy-195ea8e15ac3822c1524ee4742ec42ca76638876.tar.bz2 mitmproxy-195ea8e15ac3822c1524ee4742ec42ca76638876.zip |
Send password_manager as a general application setting instead of per handler
Diffstat (limited to 'libmproxy')
-rw-r--r-- | libmproxy/web/app.py | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/libmproxy/web/app.py b/libmproxy/web/app.py index 55711837..2c45a1dc 100644 --- a/libmproxy/web/app.py +++ b/libmproxy/web/app.py @@ -48,23 +48,20 @@ class BasicAuth(object): self._transforms = [] self.finish() - def initialize(self, **kwargs): - self.wauthenticator = kwargs.get("wauthenticator") - def prepare(self): - if self.wauthenticator: + wauthenticator = self.application.settings['wauthenticator'] + if wauthenticator: auth_header = self.request.headers.get('Authorization') if auth_header is None or not auth_header.startswith('Basic '): self.set_auth_headers() else: self.auth_decoded = base64.decodestring(auth_header[6:]) self.username, self.password = self.auth_decoded.split(':', 2) - if not self.wauthenticator.test(self.username, self.password): + if not wauthenticator.test(self.username, self.password): self.set_auth_headers() raise APIError(401, "Invalid username or password.") - class RequestHandler(BasicAuth, tornado.web.RequestHandler): def set_default_headers(self): @@ -311,9 +308,6 @@ class Application(tornado.web.Application): def __init__(self, master, debug, wauthenticator): self.master = master - self.additional_args = dict( - wauthenticator=wauthenticator, - ) handlers = [ (r"/", IndexHandler), (r"/filter-help", FiltHelp), @@ -330,14 +324,12 @@ class Application(tornado.web.Application): (r"/settings", Settings), (r"/clear", ClearAll), ] - for i, handler in enumerate(handlers): - handlers[i] += (self.additional_args,) - settings = dict( template_path=os.path.join(os.path.dirname(__file__), "templates"), static_path=os.path.join(os.path.dirname(__file__), "static"), xsrf_cookies=True, cookie_secret=os.urandom(256), debug=debug, + wauthenticator=wauthenticator, ) super(Application, self).__init__(handlers, **settings) |