From cc4210dc555678b603e80da198f512bcc15b663b Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Wed, 30 Nov 2011 18:48:33 +0100 Subject: shrink AuthenticationMiddleware.authenticate interface The method no longer receives a start_response and is no longer responsible for calling self.app. Instead it returns a dictionary with the result of the authentication. --- wsgitools/middlewares.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'wsgitools/middlewares.py') diff --git a/wsgitools/middlewares.py b/wsgitools/middlewares.py index 13ba41c..b385e91 100644 --- a/wsgitools/middlewares.py +++ b/wsgitools/middlewares.py @@ -337,9 +337,9 @@ class BasicAuthMiddleware(AuthenticationMiddleware): self.realm = realm self.app401 = app401 - def authenticate(self, auth, environ, start_response): - """wsgi interface - @type environ: {str: str} + def authenticate(self, auth, environ): + """ + @type environ: {str: object} """ assert isinstance(environ, dict) try: @@ -355,8 +355,7 @@ class BasicAuthMiddleware(AuthenticationMiddleware): except TypeError: # catch old interface result = self.check_function(username, password) if result: - environ["REMOTE_USER"] = username - return self.app(environ, start_response) + return dict(user=username) raise AuthenticationRequired("credentials not valid") def www_authenticate(self, exception): -- cgit v1.2.3