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