@@ -141,6 +141,26 @@ def handleCheckIDRequest(request, openid_request):
141141 what Simple Registration information, if any, to send in the
142142 response.
143143 """
144+ # If the request was an IDP-driven identifier selection request
145+ # (i.e., the IDP URL was entered at the RP), then return the
146+ # default identity URL for this server. In a full-featured
147+ # provider, there could be interaction with the user to determine
148+ # what URL should be sent.
149+ if not openid_request .idSelect ():
150+
151+ id_url = getViewURL (request , idPage )
152+
153+ # Confirm that this server can actually vouch for that
154+ # identifier
155+ if id_url != openid_request .identity :
156+ # Return an error response
157+ error_response = ProtocolError (
158+ openid_request .message ,
159+ "This server cannot verify the URL %r" %
160+ (openid_request .identity ,))
161+
162+ return displayResponse (request , error_response )
163+
144164 if openid_request .immediate :
145165 # Always respond with 'cancel' to immediate mode requests
146166 # because we don't track information about a logged-in user.
@@ -161,10 +181,7 @@ def showDecidePage(request, openid_request):
161181
162182 @type openid_request: openid.server.server.CheckIDRequest
163183 """
164- idSelect = openid_request .idSelect ()
165- identity = openid_request .identity
166184 trust_root = openid_request .trust_root
167- default_url = getViewURL (request , idPage )
168185 return_to = openid_request .return_to
169186
170187 try :
@@ -177,10 +194,7 @@ def showDecidePage(request, openid_request):
177194 return direct_to_template (
178195 request ,
179196 'server/trust.html' ,
180- {'idSelect' : idSelect ,
181- 'identity' : identity ,
182- 'trust_root' : trust_root ,
183- 'default_url' : default_url ,
197+ {'trust_root' : trust_root ,
184198 'trust_handler_url' :getViewURL (request , processTrustResult ),
185199 'trust_root_valid' : trust_root_valid ,
186200 })
@@ -194,31 +208,19 @@ def processTrustResult(request):
194208 # appropriate response.
195209 openid_request = getRequest (request )
196210
197- result = None
198- response_identity = openid_request . identity
211+ # The identifier that this server can vouch for
212+ response_identity = getViewURL ( request , idPage )
199213
200214 # If the decision was to allow the verification, respond
201215 # accordingly.
202- if 'allow' in request .POST :
203- result = True
204- elif 'cancel' in request .POST :
205- # Otherwise, respond with False.
206- result = False
207-
208- # If the request was an IDP-driven identifier selection request
209- # (i.e., the IDP URL was entered at the RP), look at the form to
210- # find out what identity URL the user wanted to send.
211- if openid_request .idSelect ():
212- response_identity = getViewURL (
213- request ,
214- idPage , kwargs = {'name' :request .POST ['name' ]})
216+ allowed = 'allow' in request .POST
215217
216218 # Generate a response with the appropriate answer.
217- openid_response = openid_request .answer (result ,
219+ openid_response = openid_request .answer (allowed ,
218220 identity = response_identity )
219221
220222 # Send Simple Registration data in the response, if appropriate.
221- if result :
223+ if allowed :
222224 sreg_data = {
223225 'fullname' : 'Example User' ,
224226 'nickname' : 'example' ,
0 commit comments