From d709effdbaffe75ae40fdea4a71beb8ae700e95e Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Tue, 8 Jul 2008 19:42:30 +0200 Subject: add environ param to check_function in middlewares.BasicAuthMiddleware The check_function passed to the BasicAuthMiddleware constructur will now receive a third parameter environ to check against additional things. If the function does not take a third parameter the function will be called in the old manner thus maintaining backwards compatibility. --- wsgitools/middlewares.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'wsgitools/middlewares.py') diff --git a/wsgitools/middlewares.py b/wsgitools/middlewares.py index b725565..201634b 100644 --- a/wsgitools/middlewares.py +++ b/wsgitools/middlewares.py @@ -297,7 +297,11 @@ class BasicAuthMiddleware: if auth_type.lower() != "basic" or ':' not in auth_info: return self.authorization_required(environ, start_response) username, password = auth_info.split(':', 1) - if self.check_function(username, password): + try: + result = self.check_function(username, password, environ) + except TypeError: # catch old interface + result = self.check_function(username, password) + if result: environ["REMOTE_USER"] = username return self.app(environ, start_response) return self.authorization_required(environ, start_response) -- cgit v1.2.3