@@ -921,18 +921,20 @@ def _verifyDiscoveryResultsOpenID2(self, resp_msg, endpoint):
921921 # request.
922922 if not endpoint :
923923 oidutil .log ('No pre-discovered information supplied.' )
924- endpoint = self ._discoverAndVerify (to_match )
924+ endpoint = self ._discoverAndVerify (to_match . claimed_id , [ to_match ] )
925925 else :
926926 # The claimed ID matches, so we use the endpoint that we
927927 # discovered in initiation. This should be the most common
928928 # case.
929929 try :
930930 self ._verifyDiscoverySingle (endpoint , to_match )
931931 except ProtocolError , e :
932- oidutil .log ("Error attempting to use stored discovery information: " +
933- str (e ))
932+ oidutil .log (
933+ "Error attempting to use stored discovery information: " +
934+ str (e ))
934935 oidutil .log ("Attempting discovery to verify endpoint" )
935- endpoint = self ._discoverAndVerify (to_match )
936+ endpoint = self ._discoverAndVerify (
937+ to_match .claimed_id , [to_match ])
936938
937939 # The endpoint we return should have the claimed ID from the
938940 # message we just verified, fragment and all.
@@ -979,10 +981,7 @@ def _verifyDiscoveryResultsOpenID1(self, resp_msg, endpoint):
979981 return endpoint
980982
981983 # Endpoint is either bad (failed verification) or None
982- try :
983- return self ._discoverAndVerify (to_match )
984- except TypeURIMismatch :
985- return self ._discoverAndVerify (to_match_1_0 )
984+ return self ._discoverAndVerify (claimed_id , [to_match , to_match_1_0 ])
986985
987986 def _verifyDiscoverySingle (self , endpoint , to_match ):
988987 """Verify that the given endpoint matches the information
@@ -1032,7 +1031,7 @@ def _verifyDiscoverySingle(self, endpoint, to_match):
10321031 raise ProtocolError ('OP Endpoint mismatch. Expected %s, got %s' %
10331032 (to_match .server_url , endpoint .server_url ))
10341033
1035- def _discoverAndVerify (self , to_match ):
1034+ def _discoverAndVerify (self , claimed_id , to_match_endpoints ):
10361035 """Given an endpoint object created from the information in an
10371036 OpenID response, perform discovery and verify the discovery
10381037 results, returning the matching endpoint that is the result of
@@ -1047,38 +1046,41 @@ def _discoverAndVerify(self, to_match):
10471046
10481047 @raises DiscoveryFailure: when discovery fails.
10491048 """
1050- oidutil .log ('Performing discovery on %s' % (to_match . claimed_id ,))
1051- _ , services = self ._discover (to_match . claimed_id )
1049+ oidutil .log ('Performing discovery on %s' % (claimed_id ,))
1050+ _ , services = self ._discover (claimed_id )
10521051 if not services :
10531052 raise DiscoveryFailure ('No OpenID information found at %s' %
1054- (to_match .claimed_id ,), None )
1055- return self ._verifyDiscoveredServices (services , to_match )
1053+ (claimed_id ,), None )
1054+ return self ._verifyDiscoveredServices (claimed_id , services ,
1055+ to_match_endpoints )
10561056
10571057
1058- def _verifyDiscoveredServices (self , services , to_match ):
1058+ def _verifyDiscoveredServices (self , claimed_id , services , to_match_endpoints ):
10591059 """See @L{_discoverAndVerify}"""
10601060
10611061 # Search the services resulting from discovery to find one
10621062 # that matches the information from the assertion
10631063 failure_messages = []
10641064 for endpoint in services :
1065- try :
1066- self ._verifyDiscoverySingle (endpoint , to_match )
1067- except ProtocolError , why :
1068- failure_messages .append (str (why ))
1069- else :
1070- # It matches, so discover verification has
1071- # succeeded. Return this endpoint.
1072- return endpoint
1065+ for to_match_endpoint in to_match_endpoints :
1066+ try :
1067+ self ._verifyDiscoverySingle (
1068+ endpoint , to_match_endpoint )
1069+ except ProtocolError , why :
1070+ failure_messages .append (str (why ))
1071+ else :
1072+ # It matches, so discover verification has
1073+ # succeeded. Return this endpoint.
1074+ return endpoint
10731075 else :
10741076 oidutil .log ('Discovery verification failure for %s' %
1075- (to_match . claimed_id ,))
1077+ (claimed_id ,))
10761078 for failure_message in failure_messages :
10771079 oidutil .log (' * Endpoint mismatch: ' + failure_message )
10781080
10791081 raise DiscoveryFailure (
10801082 'No matching endpoint found after discovering %s'
1081- % (to_match . claimed_id ,), None )
1083+ % (claimed_id ,), None )
10821084
10831085 def _checkAuth (self , message , server_url ):
10841086 """Make a check_authentication request to verify this message.
0 commit comments