Skip to content
Snippets Groups Projects
Commit 028e5264 authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Patch #1076414 by wojtha, c960657: Openid discovery - OpenID v1 OP service...

- Patch #1076414 by wojtha, c960657: Openid discovery - OpenID v1 OP service with lower priority is chosen instead OpenID v2 Claimed id service.
parent 05160e44
No related branches found
No related tags found
No related merge requests found
......@@ -188,32 +188,33 @@ function _openid_select_service(array $services) {
// Extensible Resource Identifier (XRI) Resolution Version 2.0, section 4.3.3:
// Find the service with the highest priority (lowest integer value). If there
// is a tie, select a random one, not just the first in the XML document.
$selected_service = NULL;
shuffle($services);
$selected_service = NULL;
$selected_type_priority = FALSE;
// Search for an OP Identifier Element.
foreach ($services as $service) {
if (!empty($service['uri'])) {
$type_priority = FALSE;
if (in_array('http://specs.openid.net/auth/2.0/server', $service['types'])) {
$service['version'] = 2;
$type_priority = 1;
}
elseif (in_array('http://specs.openid.net/auth/2.0/signon', $service['types'])) {
$service['version'] = 2;
$type_priority = 2;
}
elseif (in_array(OPENID_NS_1_0, $service['types']) || in_array(OPENID_NS_1_1, $service['types'])) {
$service['version'] = 1;
$type_priority = 3;
}
if (isset($service['version']) && (!$selected_service || $service['priority'] < $selected_service['priority'])) {
$selected_service = $service;
}
}
}
if (!$selected_service) {
// Search for Claimed Identifier Element.
foreach ($services as $service) {
if (!empty($service['uri']) && in_array('http://specs.openid.net/auth/2.0/signon', $service['types'])) {
$service['version'] = 2;
if (!$selected_service || $service['priority'] < $selected_service['priority']) {
$selected_service = $service;
}
if ($type_priority
&& (!$selected_service
|| $type_priority < $selected_type_priority
|| ($type_priority == $selected_type_priority && $service['priority'] < $selected_service['priority']))) {
$selected_service = $service;
$selected_type_priority = $type_priority;
}
}
}
......
......@@ -105,6 +105,10 @@ function openid_test_yadis_xrds() {
<Service>
<Type>http://example.com/this-is-ignored</Type>
</Service>
<Service priority="5">
<Type>http://openid.net/signon/1.0</Type>
<URI>http://example.com/this-is-only-openid-1.0</URI>
</Service>
<Service priority="10">
<Type>http://specs.openid.net/auth/2.0/signon</Type>
<Type>http://openid.net/srv/ax/1.0</Type>
......@@ -133,7 +137,7 @@ function openid_test_yadis_xrds() {
}
elseif (arg(3) == 'delegate') {
print '
<Service priority="5">
<Service priority="0">
<Type>http://specs.openid.net/auth/2.0/signon</Type>
<Type>http://openid.net/srv/ax/1.0</Type>
<URI>' . url('openid-test/endpoint', array('absolute' => TRUE)) . '</URI>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment