# HG changeset patch # User paulb # Date 1085851649 0 # Node ID 3bec83a54f0250224e625917ef46046a35c1f987 # Parent bdeff9537ada1615b93f9caa7ab3198fbeed0e7e [project @ 2004-05-29 17:27:29 by paulb] Moved the login credentials to the initialisation program. diff -r bdeff9537ada -r 3bec83a54f02 examples/Common/Login/__init__.py --- a/examples/Common/Login/__init__.py Sat May 29 17:27:16 2004 +0000 +++ b/examples/Common/Login/__init__.py Sat May 29 17:27:29 2004 +0000 @@ -56,16 +56,19 @@ class LoginAuthenticator: - credentials = ( - ("badger", "abc"), - ("vole", "xyz"), - ) + def __init__(self, secret_key, credentials, cookie_name=None): - def __init__(self, secret_key): + """ + Initialise the authenticator with a 'secret_key', the authenticator's registry of + 'credentials' and an optional 'cookie_name'. - "Initialise the authenticator with a 'secret_key'." + The 'credentials' must be an object which supports tests of the form + '(username, password) in credentials'. + """ self.secret_key = secret_key + self.credentials = credentials + self.cookie_name = cookie_name or "LoginAuthenticator" def authenticate(self, trans): @@ -89,7 +92,7 @@ # NOTE: This should be moved into a common library. trans.set_cookie_value( - "LoginAuthenticator", + self.cookie_name, username + ":" + md5.md5(username + self.secret_key).hexdigest() )