1.1 --- a/examples/Common/OpenIDLogin/__init__.py Sat Nov 14 00:50:39 2009 +0100
1.2 +++ b/examples/Common/OpenIDLogin/__init__.py Sun Nov 29 02:01:41 2009 +0100
1.3 @@ -12,6 +12,7 @@
1.4 from WebStack.Resources.Static import StringResource
1.5 import XSLForms.Resources.OpenIDLogin
1.6 from XSLForms.Resources.WebResources import output, prepare_resources as pr, resources
1.7 +import urllib
1.8
1.9 # Configuration settings.
1.10
1.11 @@ -35,12 +36,21 @@
1.12
1.13 "Return a simple Web site resource."
1.14
1.15 + # NOTE: Support "special" username due to stupid HTML 4 restrictions.
1.16 +
1.17 + special_username = urllib.quote(u"זרו".encode("utf-8"))
1.18 +
1.19 # Authentication objects.
1.20
1.21 credentials = [
1.22 - ((host + "/badger", "badger"), "abc"),
1.23 - ((host + "/vole", "vole"), "xyz"),
1.24 - ((host + u"/זרו", u"זרו"), u"ֶ״ֵ")
1.25 + # Local identifier, username, password
1.26 + ((host + "/badger", "badger"), "abc"),
1.27 + ((host + "/vole", "vole"), "xyz"),
1.28 + ((host + u"/זרו", u"זרו"), u"ֶ״ֵ"),
1.29 + ((host + "/badger2", "badger"), "abc"),
1.30 + ((host + "/vole2", "vole"), "xyz"),
1.31 + ((host + u"/זרו2", u"זרו"), u"ֶ״ֵ"),
1.32 + ((host + "/" + special_username, u"זרו"), u"ֶ״ֵ"),
1.33 ]
1.34 login_authenticator = Authenticator(credentials)
1.35
1.36 @@ -59,6 +69,7 @@
1.37 StringResource("""
1.38 <html>
1.39 <head>
1.40 + <meta http-equiv="Content-Type" content="text/html; charset="iso-8859-1" />
1.41 <link rel="openid2.provider openid.server" href="%s/login" />
1.42 <link rel="openid2.local_id openid.delegate" href="%s/badger" />
1.43 <title>Badger's Home Page</title>
1.44 @@ -67,24 +78,26 @@
1.45 <p>Home page for the OpenID authenticated user, <code>badger</code>.</p>
1.46 </body>
1.47 </html>
1.48 - """ % (host, host), ContentType("text/html")),
1.49 + """ % (host, host), ContentType("text/html", "iso-8859-1")),
1.50 u"זרו" :
1.51 StringResource(u"""
1.52 <html>
1.53 <head>
1.54 + <meta http-equiv="Content-Type" content="text/html; charset="iso-8859-1" />
1.55 <link rel="openid2.provider openid.server" href="%s/login" />
1.56 - <link rel="openid2.local_id openid.delegate" href="%s/זרו" />
1.57 + <link rel="openid2.local_id openid.delegate" href="%s/%s" />
1.58 <title>Home Page for זרו</title>
1.59 </head>
1.60 <body>
1.61 <p>Home page for the OpenID authenticated user, <code>זרו</code>.</p>
1.62 </body>
1.63 </html>
1.64 - """ % (host, host), ContentType("text/html", "iso-8859-1")),
1.65 + """ % (host, host, special_username), ContentType("text/html", "iso-8859-1")),
1.66 "vole" :
1.67 StringResource("""
1.68 <html>
1.69 <head>
1.70 + <meta http-equiv="Content-Type" content="text/html; charset="iso-8859-1" />
1.71 <link rel="openid2.provider openid.server" href="%s/login" />
1.72 <link rel="openid2.local_id openid.delegate" href="%s/vole" />
1.73 <title>Vole's Home Page</title>
1.74 @@ -93,7 +106,42 @@
1.75 <p>Home page for the OpenID authenticated user, <code>vole</code>.</p>
1.76 </body>
1.77 </html>
1.78 - """ % (host, host), ContentType("text/html"))
1.79 + """ % (host, host), ContentType("text/html", "iso-8859-1")),
1.80 +
1.81 + # OpenID 2.0 resources.
1.82 + # See: http://docs.oasis-open.org/xri/2.0/specs/cd02/xri-resolution-V2.0-cd-02.html#_Ref129424065
1.83 + # ("3.3 Media Types for XRI Resolution")
1.84 + # See: http://openid.net/specs/openid-authentication-2_0.html#discovery
1.85 + # ("7.3. Discovery")
1.86 +
1.87 + "badger2" :
1.88 + StringResource("""
1.89 + <?xml version="1.0"?>
1.90 + <Service xmlns="xri://$xrd*($v*2.0)">
1.91 + <Type>http://specs.openid.net/auth/2.0/signon</Type>
1.92 + <URI>%s/login</URI>
1.93 + <LocalID>%s/badger2</LocalID>
1.94 + </Service>
1.95 + """ % (host, host), ContentType("application/xrd+xml", "iso-8859-1")),
1.96 + u"זרו2" :
1.97 + StringResource(u"""
1.98 + <?xml version="1.0" encoding="iso-8859-1"?>
1.99 + <Service xmlns="xri://$xrd*($v*2.0)">
1.100 + <Type>http://specs.openid.net/auth/2.0/signon</Type>
1.101 + <URI>%s/login</URI>
1.102 + <LocalID>%s/זרו2</LocalID>
1.103 + </Service>
1.104 + """ % (host, host), ContentType("application/xrd+xml", "iso-8859-1")),
1.105 + "vole2" :
1.106 + StringResource("""
1.107 + <?xml version="1.0"?>
1.108 + <Service xmlns="xri://$xrd*($v*2.0)">
1.109 + <Type>http://specs.openid.net/auth/2.0/signon</Type>
1.110 + <URI>%s/login</URI>
1.111 + <LocalID>%s/vole2</LocalID>
1.112 + </Service>
1.113 + """ % (host, host), ContentType("application/xrd+xml", "iso-8859-1")),
1.114 +
1.115 })
1.116
1.117 # Wrap the resource up with information about the application root.