diff options
author | Helmut Grohne <helmut@subdivi.de> | 2008-07-08 19:42:30 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2008-07-08 19:42:30 +0200 |
commit | d709effdbaffe75ae40fdea4a71beb8ae700e95e (patch) | |
tree | a4f1cc0398eeccf6073885d2533a018fccc813a2 /wsgitools | |
parent | 6455d0aa18a923bff621dd961990063fe9d9038b (diff) | |
download | wsgitools-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')
-rw-r--r-- | wsgitools/middlewares.py | 6 |
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) |