# HG changeset patch # User paulb # Date 1078013197 0 # Node ID d53db0bc6ece207a060addee44a030b4d457cc5a # Parent 3df66055acfb1cd3ee78f4a84366bdb595443671 [project @ 2004-02-29 00:06:37 by paulb] Added an authenticator class. diff -r 3df66055acfb -r d53db0bc6ece examples/Common/Auth/__init__.py --- a/examples/Common/Auth/__init__.py Sun Feb 29 00:06:25 2004 +0000 +++ b/examples/Common/Auth/__init__.py Sun Feb 29 00:06:37 2004 +0000 @@ -9,12 +9,6 @@ "A resource demanding authentication." def respond(self, trans): - user = trans.get_user() - if user is None: - trans.set_response_code(401) - trans.set_header_value("WWW-Authenticate", 'Basic realm="AuthResource"') - return - trans.set_content_type(WebStack.Generic.ContentType("text/html")) # Write out confirmation, otherwise. @@ -28,7 +22,21 @@ """ % ( - user, + trans.get_user(), )) +class AuthAuthenticator: + + "An authenticator for the application." + + def authenticate(self, trans): + user = trans.get_user() + return user is not None + + def get_auth_type(self): + return "Basic" + + def get_realm(self): + return "AuthResource" + # vim: tabstop=4 expandtab shiftwidth=4