diff options
| author | Kevin Turner <kevin@janrain.com> | 2008-07-23 19:01:33 +0000 |
|---|---|---|
| committer | Kevin Turner <kevin@janrain.com> | 2008-07-23 19:01:33 +0000 |
| commit | 74ad7efb8fa0be73dc58dfcbcb65adc4da043813 (patch) | |
| tree | ae77082cd40b90e98ff220085ae07dfb4745d577 /examples | |
| parent | 264fe7324d2a67a1411a2c3fb1b90b1b8b25c2eb (diff) | |
| download | openid-74ad7efb8fa0be73dc58dfcbcb65adc4da043813.tar.gz | |
[project @ djopenid: add ax to consumer example]
Note: currently uses myopenid.com-compatible AX values, which are not up to date with axschema.org.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/djopenid/consumer/views.py | 24 | ||||
| -rw-r--r-- | examples/djopenid/templates/consumer/index.html | 12 |
2 files changed, 35 insertions, 1 deletions
diff --git a/examples/djopenid/consumer/views.py b/examples/djopenid/consumer/views.py index 2b4d708..97a17dc 100644 --- a/examples/djopenid/consumer/views.py +++ b/examples/djopenid/consumer/views.py @@ -83,6 +83,18 @@ def startOpenID(request): required=['dob']) auth_request.addExtension(sreg_request) + # Add Attribute Exchange request information. + ax_request = ax.FetchRequest() + # XXX - uses myOpenID-compatible schema values, which are + # not those listed at axschema.org. + ax_request.add( + ax.AttrInfo('http://schema.openid.net/namePerson', + required=True)) + ax_request.add( + ax.AttrInfo('http://schema.openid.net/contact/web/default', + required=False, count=ax.UNLIMITED_VALUES)) + auth_request.addExtension(ax_request) + # Add PAPE request information. We'll ask for # phishing-resistant auth and display any policies we get in # the response. @@ -150,9 +162,18 @@ def finishOpenID(request): # Get a Simple Registration response object if response # information was included in the OpenID response. sreg_response = {} + ax_items = {} if response.status == consumer.SUCCESS: sreg_response = sreg.SRegResponse.fromSuccessResponse(response) + ax_response = ax.FetchResponse.fromSuccessResponse(response) + ax_items = { + 'fullname': ax_response.get( + 'http://schema.openid.net/namePerson'), + 'web': ax_response.get( + 'http://schema.openid.net/contact/web/default'), + } + # Get a PAPE response object if response information was # included in the OpenID response. pape_response = None @@ -173,7 +194,8 @@ def finishOpenID(request): consumer.SUCCESS: {'url': response.getDisplayIdentifier(), 'sreg': sreg_response and sreg_response.items(), - 'pape': pape_response}, + 'ax': ax_items.items(), + 'pape': pape_response} } result = results[response.status] diff --git a/examples/djopenid/templates/consumer/index.html b/examples/djopenid/templates/consumer/index.html index ac34add..9b4926a 100644 --- a/examples/djopenid/templates/consumer/index.html +++ b/examples/djopenid/templates/consumer/index.html @@ -58,6 +58,18 @@ The server returned no Simple Registration data. {% endif %} + {% if ax %} + Attribute Exchange data returned: + + <ul> + {% for pair in ax %} + <li>{{ pair.0 }}: {{ pair.1|join:", " }}</li> + {% endfor %} + </ul> + {% else %} + The server returned no Attribute Exchange data. + {% endif %} + {% if pape %} An authentication policy response contained these policies: |
