summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Auth/OpenID/BigMath.php1
-rw-r--r--Auth/OpenID/Consumer.php8
-rw-r--r--Auth/OpenID/HMAC.php7
-rw-r--r--Auth/OpenID/Server.php2
-rw-r--r--Auth/Yadis/Manager.php8
-rw-r--r--Auth/Yadis/ParanoidHTTPFetcher.php32
-rw-r--r--Tests/Auth/OpenID/StoreTest.php25
-rw-r--r--examples/consumer/common.php20
-rw-r--r--examples/detect.php8
-rw-r--r--examples/discover.php28
-rw-r--r--examples/server/setup.php6
11 files changed, 100 insertions, 45 deletions
diff --git a/Auth/OpenID/BigMath.php b/Auth/OpenID/BigMath.php
index 7fca2dc..58b46bf 100644
--- a/Auth/OpenID/BigMath.php
+++ b/Auth/OpenID/BigMath.php
@@ -365,7 +365,6 @@ function Auth_OpenID_detectMathLibrary($exts)
{
$loaded = false;
- $hasDl = function_exists('dl');
foreach ($exts as $extension) {
if (extension_loaded($extension['extension'])) {
return $extension;
diff --git a/Auth/OpenID/Consumer.php b/Auth/OpenID/Consumer.php
index e498a24..d562e33 100644
--- a/Auth/OpenID/Consumer.php
+++ b/Auth/OpenID/Consumer.php
@@ -1183,9 +1183,11 @@ class Auth_OpenID_GenericConsumer {
function _discoverAndVerify($claimed_id, $to_match_endpoints)
{
// oidutil.log('Performing discovery on %s' % (claimed_id,))
- list($unused, $services) = call_user_func($this->discoverMethod,
- $claimed_id,
- $this->fetcher);
+ list($unused, $services) = call_user_func_array($this->discoverMethod,
+ array(
+ $claimed_id,
+ &$this->fetcher,
+ ));
if (!$services) {
return new Auth_OpenID_FailureResponse(null,
diff --git a/Auth/OpenID/HMAC.php b/Auth/OpenID/HMAC.php
index e9779bd..e6c4bdf 100644
--- a/Auth/OpenID/HMAC.php
+++ b/Auth/OpenID/HMAC.php
@@ -60,6 +60,13 @@ function Auth_OpenID_HMACSHA1($key, $text)
$key = Auth_OpenID_SHA1($key, true);
}
+ if (function_exists('hash_hmac') &&
+ function_exists('hash_algos') &&
+ (in_array('sha1', hash_algos()))) {
+ return hash_hmac('sha1', $text, $key, true);
+ }
+ // Home-made solution
+
$key = str_pad($key, Auth_OpenID_SHA1_BLOCKSIZE, chr(0x00));
$ipad = str_repeat(chr(0x36), Auth_OpenID_SHA1_BLOCKSIZE);
$opad = str_repeat(chr(0x5c), Auth_OpenID_SHA1_BLOCKSIZE);
diff --git a/Auth/OpenID/Server.php b/Auth/OpenID/Server.php
index fb7cc39..8d8b686 100644
--- a/Auth/OpenID/Server.php
+++ b/Auth/OpenID/Server.php
@@ -1704,7 +1704,7 @@ class Auth_OpenID_Server {
{
if (method_exists($this, "openid_" . $request->mode)) {
$handler = array($this, "openid_" . $request->mode);
- return call_user_func($handler, &$request);
+ return call_user_func_array($handler, array(&$request));
}
return null;
}
diff --git a/Auth/Yadis/Manager.php b/Auth/Yadis/Manager.php
index 5829de6..3f54fd0 100644
--- a/Auth/Yadis/Manager.php
+++ b/Auth/Yadis/Manager.php
@@ -411,9 +411,11 @@ class Auth_Yadis_Discovery {
if (!$manager || (!$manager->services)) {
$this->destroyManager();
- list($yadis_url, $services) = call_user_func($discover_cb,
- $this->url,
- $fetcher);
+ list($yadis_url, $services) = call_user_func_array($discover_cb,
+ array(
+ $this->url,
+ &$fetcher,
+ ));
$manager = $this->createManager($services, $yadis_url);
}
diff --git a/Auth/Yadis/ParanoidHTTPFetcher.php b/Auth/Yadis/ParanoidHTTPFetcher.php
index 4da7c94..c44adfe 100644
--- a/Auth/Yadis/ParanoidHTTPFetcher.php
+++ b/Auth/Yadis/ParanoidHTTPFetcher.php
@@ -129,9 +129,19 @@ class Auth_Yadis_ParanoidHTTPFetcher extends Auth_Yadis_HTTPFetcher {
curl_setopt($c, CURLOPT_URL, $url);
if (defined('Auth_OpenID_VERIFY_HOST')) {
- curl_setopt($c, CURLOPT_SSL_VERIFYPEER, true);
- curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 2);
+ // set SSL verification options only if Auth_OpenID_VERIFY_HOST
+ // is explicitly set, otherwise use system default.
+ if (Auth_OpenID_VERIFY_HOST) {
+ curl_setopt($c, CURLOPT_SSL_VERIFYPEER, true);
+ curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 2);
+ if (defined('Auth_OpenID_CAINFO')) {
+ curl_setopt($c, CURLOPT_CAINFO, Auth_OpenID_CAINFO);
+ }
+ } else {
+ curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
+ }
}
+
curl_exec($c);
$code = curl_getinfo($c, CURLINFO_HTTP_CODE);
@@ -153,6 +163,7 @@ class Auth_Yadis_ParanoidHTTPFetcher extends Auth_Yadis_HTTPFetcher {
curl_close($c);
if (defined('Auth_OpenID_VERIFY_HOST') &&
+ Auth_OpenID_VERIFY_HOST == true &&
$this->isHTTPS($url)) {
Auth_OpenID::log('OpenID: Verified SSL host %s using '.
'curl/get', $url);
@@ -202,8 +213,17 @@ class Auth_Yadis_ParanoidHTTPFetcher extends Auth_Yadis_HTTPFetcher {
array($this, "_writeData"));
if (defined('Auth_OpenID_VERIFY_HOST')) {
- curl_setopt($c, CURLOPT_SSL_VERIFYPEER, true);
- curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 2);
+ // set SSL verification options only if Auth_OpenID_VERIFY_HOST
+ // is explicitly set, otherwise use system default.
+ if (Auth_OpenID_VERIFY_HOST) {
+ curl_setopt($c, CURLOPT_SSL_VERIFYPEER, true);
+ curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 2);
+ if (defined('Auth_OpenID_CAINFO')) {
+ curl_setopt($c, CURLOPT_CAINFO, Auth_OpenID_CAINFO);
+ }
+ } else {
+ curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
+ }
}
curl_exec($c);
@@ -217,7 +237,9 @@ class Auth_Yadis_ParanoidHTTPFetcher extends Auth_Yadis_HTTPFetcher {
return null;
}
- if (defined('Auth_OpenID_VERIFY_HOST') && $this->isHTTPS($url)) {
+ if (defined('Auth_OpenID_VERIFY_HOST') &&
+ Auth_OpenID_VERIFY_HOST == true &&
+ $this->isHTTPS($url)) {
Auth_OpenID::log('OpenID: Verified SSL host %s using '.
'curl/post', $url);
}
diff --git a/Tests/Auth/OpenID/StoreTest.php b/Tests/Auth/OpenID/StoreTest.php
index 7c50e2f..0847619 100644
--- a/Tests/Auth/OpenID/StoreTest.php
+++ b/Tests/Auth/OpenID/StoreTest.php
@@ -23,15 +23,20 @@ require_once 'Auth/OpenID.php';
function _Auth_OpenID_mkdtemp()
{
- if (strpos(PHP_OS, 'WIN') === 0) {
- $dir = $_ENV['TMP'];
- if (!isset($dir)) {
- $dir = 'C:\Windows\Temp';
- }
- } else {
- $dir = @$_ENV['TMPDIR'];
- if (!isset($dir)) {
- $dir = '/tmp';
+ if (function_exists('sys_get_temp_dir')) {
+ $dir = sys_get_temp_dir();
+ }
+ else {
+ if (strpos(PHP_OS, 'WIN') === 0) {
+ $dir = $_ENV['TMP'];
+ if (!isset($dir)) {
+ $dir = 'C:\Windows\Temp';
+ }
+ } else {
+ $dir = @$_ENV['TMPDIR'];
+ if (!isset($dir)) {
+ $dir = '/tmp';
+ }
}
}
@@ -652,7 +657,7 @@ class Tests_Auth_OpenID_Included_StoreTest extends Tests_Auth_OpenID_Store {
// The MDB2 test can use any database engine. MySQL is chosen
// arbitrarily.
if (!(extension_loaded('mysql') ||
- @dl('mysql.' . PHP_SHLIB_SUFFIX)) ||
+ (function_exists('dl') && @dl('mysql.' . PHP_SHLIB_SUFFIX))) ||
!(@include_once 'MDB2.php')) {
print "(not testing MDB2 store)";
$this->pass();
diff --git a/examples/consumer/common.php b/examples/consumer/common.php
index 67f4273..fddc1c3 100644
--- a/examples/consumer/common.php
+++ b/examples/consumer/common.php
@@ -50,7 +50,25 @@ function &getStore() {
* created elsewhere. After you're done playing with the example
* script, you'll have to remove this directory manually.
*/
- $store_path = "/tmp/_php_consumer_test";
+ $store_path = null;
+ if (function_exists('sys_get_temp_dir')) {
+ $store_path = sys_get_temp_dir();
+ }
+ else {
+ if (strpos(PHP_OS, 'WIN') === 0) {
+ $store_path = $_ENV['TMP'];
+ if (!isset($store_path)) {
+ $dir = 'C:\Windows\Temp';
+ }
+ }
+ else {
+ $store_path = @$_ENV['TMPDIR'];
+ if (!isset($store_path)) {
+ $store_path = '/tmp';
+ }
+ }
+ }
+ $store_path .= DIRECTORY_SEPARATOR . '_php_consumer_test';
if (!file_exists($store_path) &&
!mkdir($store_path)) {
diff --git a/examples/detect.php b/examples/detect.php
index 123e496..3c13a5a 100644
--- a/examples/detect.php
+++ b/examples/detect.php
@@ -314,7 +314,7 @@ function detect_stores($r, &$out)
$found = array();
foreach (array('sqlite', 'mysql', 'pgsql') as $dbext) {
- if (extension_loaded($dbext) || (ini_get('enable_dl') && dl($dbext . '.' . PHP_SHLIB_SUFFIX))) {
+ if (extension_loaded($dbext) || (function_exists('dl') && @dl($dbext . '.' . PHP_SHLIB_SUFFIX))) {
$found[] = $dbext;
}
}
@@ -368,7 +368,7 @@ function detect_stores($r, &$out)
$out .= $r->p('If you are using the filesystem store, your ' .
'data directory must be readable and writable by ' .
- $web_user . ' and not availabe over the Web.');
+ $web_user . ' and not available over the Web.');
return true;
}
@@ -434,7 +434,7 @@ function detect_fetcher($r, &$out)
$ok = true;
$fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
- $fetch_url = 'http://gist.github.com/raw/465630/c57eff55ebc0c54973903af5f72bac72762cf4f4/helloworld';
+ $fetch_url = 'https://raw.github.com/gist/465630/c57eff55ebc0c54973903af5f72bac72762cf4f4/helloworld';
$expected_url = $fetch_url;// . '.txt';
$result = $fetcher->get($fetch_url);
@@ -455,7 +455,7 @@ function detect_fetcher($r, &$out)
if ($url == $fetch_url) {
$msg = 'The redirected URL was not returned.';
} else {
- $msg = 'An unexpected URL was returned: <' . $url . '>.';
+ $msg = 'An unexpected URL was returned: ' . $url . '.';
}
$parts[] = $r->b($msg);
}
diff --git a/examples/discover.php b/examples/discover.php
index 31e6b61..29f6718 100644
--- a/examples/discover.php
+++ b/examples/discover.php
@@ -31,7 +31,7 @@ $identifier = getOpenIDIdentifier();
<input type="text" name="openid_identifier" size="40" />
<input type="submit" value="Begin" />
</form>
-<?
+<?php
if ($identifier) {
$fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
@@ -39,27 +39,27 @@ if ($identifier) {
$identifier, $fetcher);
?>
- <h3>Discovery Results for <?= escape($identifier) ?></h3>
+ <h3>Discovery Results for <?php echo escape($identifier) ?></h3>
<table cellpadding="7" cellspacing="0">
<tbody>
<tr>
<th>Claimed Identifier</th>
- <td><?= escape($normalized_identifier) ?></td>
+ <td><?php echo escape($normalized_identifier) ?></td>
</tr>
-<?
+<?php
if (!$endpoints) {
?>
<tr>
<td colspan="2">No OpenID services discovered.</td>
</tr>
-<?
+<?php
} else {
?>
<tr>
<td colspan="2">Discovered OpenID services:</td>
</tr>
-<?
+<?php
foreach ($endpoints as $endpoint) {
?>
<tr>
@@ -67,34 +67,34 @@ foreach ($endpoints as $endpoint) {
</tr>
<tr>
<th>Server URL</th>
- <td><tt><?= escape($endpoint->server_url) ?></tt></td>
+ <td><tt><?php echo escape($endpoint->server_url) ?></tt></td>
</tr>
<tr>
<th>Local ID</th>
- <td><tt><?= escape($endpoint->local_id) ?></tt></td>
+ <td><tt><?php echo escape($endpoint->local_id) ?></tt></td>
</tr>
<tr>
<td colspan="2">
<h3>Service types:</h3>
<ul>
-<?
+<?php
foreach ($endpoint->type_uris as $type_uri) {
?>
- <li><tt><?= escape($type_uri) ?></tt></li>
-<?
+ <li><tt><?php echo escape($type_uri) ?></tt></li>
+<?php
}
?>
</ul>
</td>
</tr>
-<?
+<?php
}
}
?>
</tbody>
</table>
-<?
+<?php
}
?>
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/examples/server/setup.php b/examples/server/setup.php
index e25ef34..0a42bff 100644
--- a/examples/server/setup.php
+++ b/examples/server/setup.php
@@ -176,19 +176,19 @@ function render_form() {
$sqlite_found = false;
if (extension_loaded('sqlite') ||
- @dl('sqlite.' . PHP_SHLIB_SUFFIX)) {
+ (function_exists('dl') && @dl('sqlite.' . PHP_SHLIB_SUFFIX))) {
$sqlite_found = true;
}
$mysql_found = false;
if (extension_loaded('mysql') ||
- @dl('mysql.' . PHP_SHLIB_SUFFIX)) {
+ (function_exists('dl') && @dl('mysql.' . PHP_SHLIB_SUFFIX))) {
$mysql_found = true;
}
$pgsql_found = false;
if (extension_loaded('pgsql') ||
- @dl('pgsql.' . PHP_SHLIB_SUFFIX)) {
+ (function_exists('dl') && @dl('pgsql.' . PHP_SHLIB_SUFFIX))) {
$pgsql_found = true;
}