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', using the given 14 'initiation_url' for the OpenID initiation page, and the specified 15 'secret_key' for authentication tokens. 16 """ 17 18 return MapResource({ 19 "simple" : 20 OpenIDRedirectResource( 21 login_url=initiation_url, 22 app_url=app_url, 23 resource=SimpleResource(), 24 authenticator=OpenIDRedirectAuthenticator( 25 secret_key=secret_key, 26 app_url=app_url 27 ), 28 anonymous_parameter_name="anonymous", 29 logout_parameter_name="logout" 30 ), 31 32 # The "login" is really OpenID initiation. 33 34 "login" : OpenIDInitiationResource(), 35 36 # A root page. 37 38 "" : 39 StringResource(""" 40 <html> 41 <head> 42 <title>Simple Application with OpenID Login</title> 43 </head> 44 <body> 45 <p>Access the application <a href="simple">here</a>.</p> 46 </body> 47 </html> 48 """, ContentType("text/html")) 49 50 }) 51 52 # vim: tabstop=4 expandtab shiftwidth=4