Skip to content

Commit 74ad7ef

Browse files
author
Kevin Turner
committed
[project @ djopenid: add ax to consumer example]
Note: currently uses myopenid.com-compatible AX values, which are not up to date with axschema.org.
1 parent 264fe73 commit 74ad7ef

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

examples/djopenid/consumer/views.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ def startOpenID(request):
8383
required=['dob'])
8484
auth_request.addExtension(sreg_request)
8585

86+
# Add Attribute Exchange request information.
87+
ax_request = ax.FetchRequest()
88+
# XXX - uses myOpenID-compatible schema values, which are
89+
# not those listed at axschema.org.
90+
ax_request.add(
91+
ax.AttrInfo('http://schema.openid.net/namePerson',
92+
required=True))
93+
ax_request.add(
94+
ax.AttrInfo('http://schema.openid.net/contact/web/default',
95+
required=False, count=ax.UNLIMITED_VALUES))
96+
auth_request.addExtension(ax_request)
97+
8698
# Add PAPE request information. We'll ask for
8799
# phishing-resistant auth and display any policies we get in
88100
# the response.
@@ -150,9 +162,18 @@ def finishOpenID(request):
150162
# Get a Simple Registration response object if response
151163
# information was included in the OpenID response.
152164
sreg_response = {}
165+
ax_items = {}
153166
if response.status == consumer.SUCCESS:
154167
sreg_response = sreg.SRegResponse.fromSuccessResponse(response)
155168

169+
ax_response = ax.FetchResponse.fromSuccessResponse(response)
170+
ax_items = {
171+
'fullname': ax_response.get(
172+
'http://schema.openid.net/namePerson'),
173+
'web': ax_response.get(
174+
'http://schema.openid.net/contact/web/default'),
175+
}
176+
156177
# Get a PAPE response object if response information was
157178
# included in the OpenID response.
158179
pape_response = None
@@ -173,7 +194,8 @@ def finishOpenID(request):
173194
consumer.SUCCESS:
174195
{'url': response.getDisplayIdentifier(),
175196
'sreg': sreg_response and sreg_response.items(),
176-
'pape': pape_response},
197+
'ax': ax_items.items(),
198+
'pape': pape_response}
177199
}
178200

179201
result = results[response.status]

examples/djopenid/templates/consumer/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@
5858
The server returned no Simple Registration data.
5959
{% endif %}
6060

61+
{% if ax %}
62+
Attribute Exchange data returned:
63+
64+
<ul>
65+
{% for pair in ax %}
66+
<li>{{ pair.0 }}: {{ pair.1|join:", " }}</li>
67+
{% endfor %}
68+
</ul>
69+
{% else %}
70+
The server returned no Attribute Exchange data.
71+
{% endif %}
72+
6173
{% if pape %}
6274
An authentication policy response contained these policies:
6375

0 commit comments

Comments
 (0)