# HG changeset patch # User Paul Boddie # Date 1259456501 -3600 # Node ID fd003deb4d5942b0c31a82b7d6ec6fd501bcb941 # Parent 19ca9b0d9f4dc1daccc789c576cb3567d967308e Added fixes from the WebStack example involving credentials, non-ASCII characters, and some XRD-based resources. diff -r 19ca9b0d9f4d -r fd003deb4d59 examples/Common/OpenIDLogin/__init__.py --- a/examples/Common/OpenIDLogin/__init__.py Sat Nov 14 00:50:39 2009 +0100 +++ b/examples/Common/OpenIDLogin/__init__.py Sun Nov 29 02:01:41 2009 +0100 @@ -12,6 +12,7 @@ from WebStack.Resources.Static import StringResource import XSLForms.Resources.OpenIDLogin from XSLForms.Resources.WebResources import output, prepare_resources as pr, resources +import urllib # Configuration settings. @@ -35,12 +36,21 @@ "Return a simple Web site resource." + # NOTE: Support "special" username due to stupid HTML 4 restrictions. + + special_username = urllib.quote(u"זרו".encode("utf-8")) + # Authentication objects. credentials = [ - ((host + "/badger", "badger"), "abc"), - ((host + "/vole", "vole"), "xyz"), - ((host + u"/זרו", u"זרו"), u"ֶ״ֵ") + # Local identifier, username, password + ((host + "/badger", "badger"), "abc"), + ((host + "/vole", "vole"), "xyz"), + ((host + u"/זרו", u"זרו"), u"ֶ״ֵ"), + ((host + "/badger2", "badger"), "abc"), + ((host + "/vole2", "vole"), "xyz"), + ((host + u"/זרו2", u"זרו"), u"ֶ״ֵ"), + ((host + "/" + special_username, u"זרו"), u"ֶ״ֵ"), ] login_authenticator = Authenticator(credentials) @@ -59,6 +69,7 @@ StringResource(""" + Badger's Home Page @@ -67,24 +78,26 @@

Home page for the OpenID authenticated user, badger.

- """ % (host, host), ContentType("text/html")), + """ % (host, host), ContentType("text/html", "iso-8859-1")), u"זרו" : StringResource(u""" + - + Home Page for זרו

Home page for the OpenID authenticated user, זרו.

- """ % (host, host), ContentType("text/html", "iso-8859-1")), + """ % (host, host, special_username), ContentType("text/html", "iso-8859-1")), "vole" : StringResource(""" + Vole's Home Page @@ -93,7 +106,42 @@

Home page for the OpenID authenticated user, vole.

- """ % (host, host), ContentType("text/html")) + """ % (host, host), ContentType("text/html", "iso-8859-1")), + + # OpenID 2.0 resources. + # See: http://docs.oasis-open.org/xri/2.0/specs/cd02/xri-resolution-V2.0-cd-02.html#_Ref129424065 + # ("3.3 Media Types for XRI Resolution") + # See: http://openid.net/specs/openid-authentication-2_0.html#discovery + # ("7.3. Discovery") + + "badger2" : + StringResource(""" + + + http://specs.openid.net/auth/2.0/signon + %s/login + %s/badger2 + + """ % (host, host), ContentType("application/xrd+xml", "iso-8859-1")), + u"זרו2" : + StringResource(u""" + + + http://specs.openid.net/auth/2.0/signon + %s/login + %s/זרו2 + + """ % (host, host), ContentType("application/xrd+xml", "iso-8859-1")), + "vole2" : + StringResource(""" + + + http://specs.openid.net/auth/2.0/signon + %s/login + %s/vole2 + + """ % (host, host), ContentType("application/xrd+xml", "iso-8859-1")), + }) # Wrap the resource up with information about the application root.