summaryrefslogtreecommitdiff
path: root/wsgitools/digest.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2011-11-30 18:48:33 +0100
committerHelmut Grohne <helmut@subdivi.de>2011-11-30 18:48:33 +0100
commitcc4210dc555678b603e80da198f512bcc15b663b (patch)
tree716701b594a4e8458cbaf7a6be5b2d1c99ba252f /wsgitools/digest.py
parent18ffdf8301a29f35d3a549d3e96dcb0c7aa23d0b (diff)
downloadwsgitools-cc4210dc555678b603e80da198f512bcc15b663b.tar.gz
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.
Diffstat (limited to 'wsgitools/digest.py')
-rw-r--r--wsgitools/digest.py11
1 files changed, 3 insertions, 8 deletions
diff --git a/wsgitools/digest.py b/wsgitools/digest.py
index 628eac5..fc8e310 100644
--- a/wsgitools/digest.py
+++ b/wsgitools/digest.py
@@ -657,9 +657,7 @@ class AuthDigestMiddleware(AuthenticationMiddleware):
assert hasattr(store, "checknonce")
self.noncestore = store
- def authenticate(self, auth, environ, start_response):
- """wsgi interface"""
-
+ def authenticate(self, auth, environ):
try:
credentials = parse_digest_response(auth)
except ValueError:
@@ -702,17 +700,14 @@ class AuthDigestMiddleware(AuthenticationMiddleware):
if response is None or response != credresponse:
raise AuthenticationRequired("wrong response")
- environ["REMOTE_USER"] = credentials["username"]
digest = dict(nextnonce=self.noncestore.newnonce())
if "qop" in credentials:
digest["qop"] = "auth"
digest["cnonce"] = credentials["cnonce"] # no KeyError
digest["rspauth"] = self.auth_response(credentials, "")
challenge = ", ".join(map('%s="%s"'.__mod__, digest.items()))
- def modified_start_response(status, headers, exc_info=None):
- headers.append(("Authentication-Info", challenge))
- return start_response(status, headers, exc_info)
- return self.app(environ, modified_start_response)
+ return dict(user=credentials["username"],
+ outheaders=[("Authentication-Info", challenge)])
def auth_response(self, credentials, reqmethod):
"""internal method generating authentication tokens