diff options
author | Helmut Grohne <helmut@subdivi.de> | 2011-11-28 19:16:10 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2011-11-28 19:16:10 +0100 |
commit | 18ffdf8301a29f35d3a549d3e96dcb0c7aa23d0b (patch) | |
tree | ffc2ce0e6dbd8a0edd37cd51e62a1c0788a02c6f /wsgitools/digest.py | |
parent | 91eeb7df51850ebfb28db28642ed6af1c9ffe93a (diff) | |
download | wsgitools-18ffdf8301a29f35d3a549d3e96dcb0c7aa23d0b.tar.gz |
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.
Diffstat (limited to 'wsgitools/digest.py')
-rw-r--r-- | wsgitools/digest.py | 12 |
1 files 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) |