Digest HTTP/1.1 Authentication
This module implements Digest authentication as described by RFC 2617 [2] . At this time, this implementation does not provide for further challenges, nor does it support Authentication-Info header. It also uses md5, and an option to use sha would be a good thing.
Digest authentication is similar to basic authentication but rather than sending the password unencrypted you send an encrypted digest so the security is slightly better.
The code looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | from authkit.authenticate import middleware, sample_app from authkit.authenticate.digest import digest_password def digest(environ, realm, username): password = username return digest_password(realm, username, password) app = middleware( sample_app, setup_method='digest', digest_realm='Test Realm', digest_authenticate_function=digest ) if __name__ == '__main__': from paste.httpserver import serve serve(app, host='0.0.0.0', port=8080) |
Note that the digest() function takes different parameters from the valid() function we used in the HTTP basic authentication. Also rather than returing True or False the function should use the digest_password() function from authkit.middleware.digest to return a digest.
| [2] | http://www.faqs.org/rfcs/rfc2617.html |