#NEWLINE# def setup_server( ) : #NEWLINE# #INDENT# class Root ( ) : #NEWLINE# #INDENT# def index( self ) : #NEWLINE# #INDENT# return 'This is public.' #NEWLINE# #UNINDENT# index . exposed = True #NEWLINE# #UNINDENT# class DigestProtected ( ) : #NEWLINE# #INDENT# def index( self ) : #NEWLINE# #INDENT# return ( "Hello %s, you've been authorized." % cherrypy . request . login ) #NEWLINE# #UNINDENT# index . exposed = True #NEWLINE# #UNINDENT# def fetch_users( ) : #NEWLINE# #INDENT# return { #NEWLINE# #INDENT# 'test' : 'test' , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# get_ha1 = cherrypy . lib . auth_digest . get_ha1_dict_plain ( fetch_users ( ) ) #NEWLINE# conf = { #NEWLINE# #INDENT# '/digest' : { #NEWLINE# #INDENT# 'tools.auth_digest.on' : True , #NEWLINE# 'tools.auth_digest.realm' : 'localhost' , #NEWLINE# 'tools.auth_digest.get_ha1' : get_ha1 , #NEWLINE# 'tools.auth_digest.key' : 'a565c27146791cfb' , #NEWLINE# 'tools.auth_digest.debug' : 'True' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# root = Root ( ) #NEWLINE# root . digest = DigestProtected ( ) #NEWLINE# cherrypy . tree . mount ( root , config = root )