1 #!/usr/bin/env python 2 3 from WebStack.Generic import ContentType 4 from WebStack.Resources.OpenIDRedirect import OpenIDRedirectResource, OpenIDRedirectAuthenticator 5 from WebStack.Resources.OpenIDInitiation import OpenIDInitiationResource 6 from WebStack.Resources.ResourceMap import MapResource 7 from WebStack.Resources.Static import StringResource 8 from Simple import SimpleResource 9 10 def get_site_map(app_url, initiation_url, secret_key): 11 12 """ 13 Resource a resource for the site having the given 'app_url' and 14 'initiation_url', using the given 'secret_key' for authentication tokens. 15 """ 16 17 return MapResource({ 18 "simple" : 19 OpenIDRedirectResource( 20 login_url=initiation_url, 21 app_url=app_url, 22 resource=SimpleResource(), 23 authenticator=OpenIDRedirectAuthenticator( 24 secret_key=secret_key, 25 app_url=app_url 26 ), 27 anonymous_parameter_name="anonymous", 28 logout_parameter_name="logout" 29 ), 30 31 # The "login" is really OpenID initiation. 32 33 "login" : OpenIDInitiationResource(), 34 35 # A root page. 36 37 "" : 38 StringResource(""" 39 <html> 40 <head> 41 <title>Simple Application with OpenID Login</title> 42 </head> 43 <body> 44 <p>Access the application <a href="simple">here</a>.</p> 45 </body> 46 </html> 47 """, ContentType("text/html")) 48 49 }) 50 51 # vim: tabstop=4 expandtab shiftwidth=4