summaryrefslogtreecommitdiff
path: root/wsgitools/digest.py
diff options
context:
space:
mode:
Diffstat (limited to 'wsgitools/digest.py')
-rwxr-xr-xwsgitools/digest.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/wsgitools/digest.py b/wsgitools/digest.py
index 19fb975..28fb9c7 100755
--- a/wsgitools/digest.py
+++ b/wsgitools/digest.py
@@ -50,7 +50,9 @@ class AuthTokenGenerator:
self.getpass = getpass
def __call__(self, username, algo="md5"):
"""Generates an authentification token from a username.
- @type username: str"""
+ @type username: str
+ @rtype: str
+ """
assert algo.lower() in ["md5", "md5-sess"]
password = self.getpass(username)
if password is None:
@@ -161,7 +163,10 @@ class AuthDigestMiddleware:
return self.app(environ, modified_start_response)
def auth_response(self, credentials, reqmethod):
- """internal method generating authentication tokens"""
+ """internal method generating authentication tokens
+ @raise KeyError:
+ @raise ValueError:
+ """
username = credentials["username"]
algo = credentials["algorithm"]
uri = credentials["uri"]
@@ -191,7 +196,10 @@ class AuthDigestMiddleware:
self.nonces.pop(0)
def is_nonce(self, credentials):
- """internal method checking whether a nonce might be from this server"""
+ """internal method checking whether a nonce might be from this server
+ @raise KeyError:
+ @raise ValueError:
+ """
nonce = credentials["nonce"] # raises KeyError
# raises ValueError
nonce_time, nonce_value, nonce_hash = nonce.split(':')
@@ -200,7 +208,10 @@ class AuthDigestMiddleware:
return nonce_hash == token
def check_nonce(self, credentials):
- """internal method checking nonce validity"""
+ """internal method checking nonce validity
+ @raise KeyError:
+ @raise ValueError:
+ """
nonce = credentials["nonce"]
# raises ValueError
nonce_time, nonce_value, nonce_hash = nonce.split(':')