1.1 --- a/examples/Common/Login/__init__.py Sat May 29 17:27:16 2004 +0000
1.2 +++ b/examples/Common/Login/__init__.py Sat May 29 17:27:29 2004 +0000
1.3 @@ -56,16 +56,19 @@
1.4
1.5 class LoginAuthenticator:
1.6
1.7 - credentials = (
1.8 - ("badger", "abc"),
1.9 - ("vole", "xyz"),
1.10 - )
1.11 + def __init__(self, secret_key, credentials, cookie_name=None):
1.12
1.13 - def __init__(self, secret_key):
1.14 + """
1.15 + Initialise the authenticator with a 'secret_key', the authenticator's registry of
1.16 + 'credentials' and an optional 'cookie_name'.
1.17
1.18 - "Initialise the authenticator with a 'secret_key'."
1.19 + The 'credentials' must be an object which supports tests of the form
1.20 + '(username, password) in credentials'.
1.21 + """
1.22
1.23 self.secret_key = secret_key
1.24 + self.credentials = credentials
1.25 + self.cookie_name = cookie_name or "LoginAuthenticator"
1.26
1.27 def authenticate(self, trans):
1.28
1.29 @@ -89,7 +92,7 @@
1.30 # NOTE: This should be moved into a common library.
1.31
1.32 trans.set_cookie_value(
1.33 - "LoginAuthenticator",
1.34 + self.cookie_name,
1.35 username + ":" + md5.md5(username + self.secret_key).hexdigest()
1.36 )
1.37