From 18ffdf8301a29f35d3a549d3e96dcb0c7aa23d0b Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Mon, 28 Nov 2011 19:16:10 +0100 Subject: digest: generate Authentication-Info before invoking app This shrinks the possibility of raising something from start_response and maybe enables to factor out this start_response modification later. --- wsgitools/digest.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wsgitools/digest.py b/wsgitools/digest.py index c98517f..628eac5 100644 --- a/wsgitools/digest.py +++ b/wsgitools/digest.py @@ -703,13 +703,13 @@ class AuthDigestMiddleware(AuthenticationMiddleware): 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): - 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())) headers.append(("Authentication-Info", challenge)) return start_response(status, headers, exc_info) return self.app(environ, modified_start_response) -- cgit v1.2.3