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 ), 28 29 # The "login" is really OpenID initiation. 30 31 "login" : OpenIDInitiationResource(), 32 33 # A root page. 34 35 "" : 36 StringResource(""" 37 <html> 38 <head> 39 <title>Simple Application with OpenID Login</title> 40 </head> 41 <body> 42 <p>Access the application <a href="simple">here</a>.</p> 43 </body> 44 </html> 45 """, ContentType("text/html")) 46 47 }) 48 49 # vim: tabstop=4 expandtab shiftwidth=4