paul@766 | 1 | #!/usr/bin/env python |
paul@766 | 2 | |
paul@766 | 3 | from WebStack.Generic import ContentType |
paul@766 | 4 | from WebStack.Resources.LoginRedirect import LoginRedirectResource, LoginRedirectAuthenticator |
paul@766 | 5 | from WebStack.Resources.Login import LoginResource, LoginAuthenticator |
paul@766 | 6 | from WebStack.Resources.ResourceMap import MapResource |
paul@766 | 7 | from Simple import SimpleResource |
paul@766 | 8 | |
paul@766 | 9 | def get_site_map(app_url, login_url, secret_key): |
paul@766 | 10 | |
paul@766 | 11 | """ |
paul@766 | 12 | Resource a resource for the site having the given 'app_url' and 'login_url', |
paul@766 | 13 | using the given 'secret_key' for authentication tokens. |
paul@766 | 14 | """ |
paul@766 | 15 | |
paul@766 | 16 | simple = LoginRedirectResource( |
paul@766 | 17 | login_url=login_url, |
paul@766 | 18 | app_url=app_url, |
paul@766 | 19 | resource=SimpleResource(), |
paul@766 | 20 | authenticator=LoginRedirectAuthenticator(secret_key=secret_key) |
paul@766 | 21 | ) |
paul@766 | 22 | |
paul@766 | 23 | simple.anonymous_parameter_name = "anonymous" |
paul@766 | 24 | simple.logout_parameter_name = "logout" |
paul@766 | 25 | |
paul@766 | 26 | return MapResource({ |
paul@766 | 27 | "simple" : simple, |
paul@766 | 28 | "login" : |
paul@766 | 29 | LoginResource( |
paul@766 | 30 | LoginAuthenticator( |
paul@766 | 31 | secret_key=secret_key, |
paul@766 | 32 | credentials=( |
paul@766 | 33 | ("badger", "abc"), |
paul@766 | 34 | ("vole", "xyz"), |
paul@766 | 35 | ) |
paul@766 | 36 | ) |
paul@766 | 37 | ), |
paul@766 | 38 | "" : simple |
paul@766 | 39 | }) |
paul@766 | 40 | |
paul@766 | 41 | # vim: tabstop=4 expandtab shiftwidth=4 |