summaryrefslogtreecommitdiff
path: root/wsgitools/middlewares.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2008-07-08 19:42:30 +0200
committerHelmut Grohne <helmut@subdivi.de>2008-07-08 19:42:30 +0200
commitd709effdbaffe75ae40fdea4a71beb8ae700e95e (patch)
treea4f1cc0398eeccf6073885d2533a018fccc813a2 /wsgitools/middlewares.py
parent6455d0aa18a923bff621dd961990063fe9d9038b (diff)
downloadwsgitools-d709effdbaffe75ae40fdea4a71beb8ae700e95e.tar.gz
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.
Diffstat (limited to 'wsgitools/middlewares.py')
-rw-r--r--wsgitools/middlewares.py6
1 files changed, 5 insertions, 1 deletions
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)