Skip to content

Commit c21ba1f

Browse files
author
Lilli
committed
Added the following patch from the [email protected] mailing list:
http://lists.openidenabled.com/pipermail/dev/attachments/20080821/1eded806/attachment-0001.bin Original Message: will at willnorris.com Thu Aug 21 18:43:28 PDT 2008 darcs patch: seperate provider and consumer xrds types "Currently, the five OpenID Provider service types (OpenID 1.0 - 1.2, and the two for OpenID 2.0) are combined with the one OpenID Consumer service type (return_to). This causes a potential false positive when performing discovery on an endpoint. If a php-openid consumer performs discovery on another consumer which has a published return_to service type, php-openid will think it is a valid OpenID Server service type and send an authentication request to the URI. Similarly, when checking the return_to URL of a consumer, if the consumer has any of the OpenID Server service types published, a php-openid server object will try to treat one of those URIs as a published return_to URL. This scenario is actually fairly common... many personal blogs serve as both an OpenID Server (for the blog owner) as well as an OpenID consumer (for people who comment on the blog)." This patch was in the form of a Darcs patch, not a normal patch. So solve this, I applied it to the Darcs repository found on openidenabled, then created a new diff file between the original Darcs repo and the new one (with the patch applied) so that I could apply it to this git repo. It should be noted that all 3 hunks for Discover.php and the 1st hunk for TrustRoot.php were applied successfully, but the second hunk for TrustRoot failed. It seems that all it was doing was removing trailing endlines from the file, so I think it should be ok.
1 parent a2aa5e5 commit c21ba1f

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

Auth/OpenID/Discover.php

+38-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ function Auth_OpenID_getOpenIDTypeURIs()
2828
Auth_OpenID_TYPE_2_0,
2929
Auth_OpenID_TYPE_1_2,
3030
Auth_OpenID_TYPE_1_1,
31-
Auth_OpenID_TYPE_1_0,
32-
Auth_OpenID_RP_RETURN_TO_URL_TYPE);
31+
Auth_OpenID_TYPE_1_0);
32+
}
33+
34+
function Auth_OpenID_getOpenIDConsumerTypeURIs()
35+
{
36+
return array(Auth_OpenID_RP_RETURN_TO_URL_TYPE);
3337
}
3438

3539

@@ -193,6 +197,25 @@ function getLocalID()
193197
}
194198
}
195199

200+
/*
201+
* Parse the given document as XRDS looking for OpenID consumer services.
202+
*
203+
* @return array of Auth_OpenID_ServiceEndpoint or null if the
204+
* document cannot be parsed.
205+
*/
206+
function consumerFromXRDS($uri, $xrds_text)
207+
{
208+
$xrds =& Auth_Yadis_XRDS::parseXRDS($xrds_text);
209+
210+
if ($xrds) {
211+
$yadis_services =
212+
$xrds->services(array('filter_MatchesAnyOpenIDConsumerType'));
213+
return Auth_OpenID_makeOpenIDEndpoints($uri, $yadis_services);
214+
}
215+
216+
return null;
217+
}
218+
196219
/*
197220
* Parse the given document as XRDS looking for OpenID services.
198221
*
@@ -340,6 +363,19 @@ function filter_MatchesAnyOpenIDType(&$service)
340363
return false;
341364
}
342365

366+
function filter_MatchesAnyOpenIDConsumerType(&$service)
367+
{
368+
$uris = $service->getTypes();
369+
370+
foreach ($uris as $uri) {
371+
if (in_array($uri, Auth_OpenID_getOpenIDConsumerTypeURIs())) {
372+
return true;
373+
}
374+
}
375+
376+
return false;
377+
}
378+
343379
function Auth_OpenID_bestMatchingService($service, $preferred_types)
344380
{
345381
// Return the index of the first matching type, or something

Auth/OpenID/TrustRoot.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ function Auth_OpenID_getAllowedReturnURLs($relying_party_url, &$fetcher,
401401
$discover_function = array('Auth_Yadis_Yadis', 'discover');
402402
}
403403

404-
$xrds_parse_cb = array('Auth_OpenID_ServiceEndpoint', 'fromXRDS');
404+
$xrds_parse_cb = array('Auth_OpenID_ServiceEndpoint', 'consumerFromXRDS');
405405

406406
list($rp_url_after_redirects, $endpoints) =
407407
Auth_Yadis_getServiceEndpoints($relying_party_url, $xrds_parse_cb,

0 commit comments

Comments
 (0)