1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/examples/BaseHTTPRequestHandler/OpenIDLoginApp.py Mon Nov 12 00:51:58 2007 +0000
1.3 @@ -0,0 +1,59 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +from WebStack.Adapters.BaseHTTPRequestHandler import deploy
1.7 +from WebStack.Resources.OpenIDLogin import OpenIDLoginResource, Authenticator
1.8 +from WebStack.Resources.ResourceMap import MapResource
1.9 +from WebStack.Resources.Static import StringResource
1.10 +from WebStack.Generic import ContentType
1.11 +
1.12 +app_url = "http://localhost:8081" # No trailing "/"!
1.13 +
1.14 +print "Serving..."
1.15 +deploy(
1.16 + MapResource({
1.17 + "login" :
1.18 + OpenIDLoginResource(
1.19 + app_url=app_url,
1.20 + authenticator=Authenticator(
1.21 + credentials=(
1.22 + # Local identifier, username, password
1.23 + ((app_url + "/badger", "badger"), "abc"),
1.24 + ((app_url + "/vole", "vole"), "xyz"),
1.25 + )
1.26 + )
1.27 + ),
1.28 +
1.29 + # Some local OpenID pages.
1.30 +
1.31 + "badger" :
1.32 + StringResource("""
1.33 + <html>
1.34 + <head>
1.35 + <link rel="openid2.provider openid.server" href="%s/login" />
1.36 + <link rel="openid2.local_id openid.delegate" href="%s/badger" />
1.37 + <title>Badger's Home Page</title>
1.38 + </head>
1.39 + <body>
1.40 + <p>Home page for the OpenID authenticated user, <code>badger</code>.</p>
1.41 + </body>
1.42 + </html>
1.43 + """ % (app_url, app_url), ContentType("text/html")),
1.44 + "vole" :
1.45 + StringResource("""
1.46 + <html>
1.47 + <head>
1.48 + <link rel="openid2.provider openid.server" href="%s/login" />
1.49 + <link rel="openid2.local_id openid.delegate" href="%s/vole" />
1.50 + <title>Vole's Home Page</title>
1.51 + </head>
1.52 + <body>
1.53 + <p>Home page for the OpenID authenticated user, <code>vole</code>.</p>
1.54 + </body>
1.55 + </html>
1.56 + """ % (app_url, app_url), ContentType("text/html"))
1.57 + }),
1.58 + address=("", 8081),
1.59 + handle_errors=0
1.60 +)
1.61 +
1.62 +# vim: tabstop=4 expandtab shiftwidth=4