Compare commits

..

16 Commits

Author SHA1 Message Date
Rob Janssen 39db2654a6 Update README.md 2018-06-06 01:56:01 +02:00
RobThree 4ac2670429 * Try older PHP versions for the last time 2018-06-06 01:50:29 +02:00
RobThree 5de91c2837 * Ignore deprecation message for mcrypt_create_iv for PHP7.1+ 2018-06-06 01:49:21 +02:00
RobThree 0ac68f6b86 * Fix PHP7.2 issue with HashRNGProvider
* Fix PHP7.1+ issue with MCryptRNGProvider
2018-06-06 01:47:03 +02:00
RobThree fac4ebd44b * Remove time.google.com to see if that will make travis build again 2018-06-06 01:38:51 +02:00
RobThree ad8b7ab3e8 * Trying some build configurations 2018-06-06 01:35:56 +02:00
RobThree d7e8ad8e23 * Trying some build configurations 2018-06-06 01:32:25 +02:00
RobThree b8befc5aff * Put back conditional phpunit running 2018-06-06 01:15:37 +02:00
RobThree 37fbb99ac5 * Run phpunit for all versions 2018-06-06 00:58:30 +02:00
RobThree ea9b87fe32 * Changed time.windows.com to time.google.com (doesn't affect anything except that it should stop travis from failing) 2018-06-06 00:53:02 +02:00
RobThree 4f2364fef4 * Add whitelist to phpunit.xml 2018-06-05 23:05:08 +02:00
RobThree e4ec94e14d * Drop PHP 5.3 again
* Add phpunit.xml
2018-06-05 23:02:37 +02:00
RobThree de210192a7 * Put back PHP 5.3 support 2018-06-05 22:46:16 +02:00
RobThree f25b910be9 * Put back phpunit in travis.yml 2018-06-05 22:42:00 +02:00
RobThree b591c879a1 * Put back dist: trusty in travis.yml 2018-06-05 22:39:47 +02:00
RobThree 4408ce7884 * Dropped support for PHP 5.3
* Added support for PHP 7.2
2018-06-05 22:36:40 +02:00
7 changed files with 36 additions and 16 deletions
+5 -8
View File
@@ -1,18 +1,15 @@
language: php language: php
dist: trusty
matrix:
include:
- php: 5.3
dist: precise
php: php:
- 5.4 - 5.4
- 5.5 - 5.5
- 5.6 - 5.6
- 7.0 - 7.0
- 7.1 - 7.1
- hhvm - 7.2
before_script:
- composer install
script: script:
- if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then phpunit --coverage-text tests ; fi - vendor/bin/phpunit --coverage-text tests
+1 -1
View File
@@ -10,7 +10,7 @@ PHP library for [two-factor (or multi-factor) authentication](http://en.wikipedi
## Requirements ## Requirements
* Tested on PHP 5.3, 5.4, 5.5 and 5.6, 7.0, 7.1 and HHVM * Tested on PHP 5.4 up to 7.2
* [cURL](http://php.net/manual/en/book.curl.php) when using the provided `GoogleQRCodeProvider` (default), `QRServerProvider` or `QRicketProvider` but you can also provide your own QR-code provider. * [cURL](http://php.net/manual/en/book.curl.php) when using the provided `GoogleQRCodeProvider` (default), `QRServerProvider` or `QRicketProvider` but you can also provide your own QR-code provider.
* [random_bytes()](http://php.net/manual/en/function.random-bytes.php), [MCrypt](http://php.net/manual/en/book.mcrypt.php), [OpenSSL](http://php.net/manual/en/book.openssl.php) or [Hash](http://php.net/manual/en/book.hash.php) depending on which built-in RNG you use (TwoFactorAuth will try to 'autodetect' and use the best available); however: feel free to provide your own (CS)RNG. * [random_bytes()](http://php.net/manual/en/function.random-bytes.php), [MCrypt](http://php.net/manual/en/book.mcrypt.php), [OpenSSL](http://php.net/manual/en/book.openssl.php) or [Hash](http://php.net/manual/en/book.hash.php) depending on which built-in RNG you use (TwoFactorAuth will try to 'autodetect' and use the best available); however: feel free to provide your own (CS)RNG.
+1
View File
@@ -65,5 +65,6 @@
<Content Include="logo.png" /> <Content Include="logo.png" />
<Content Include="multifactorauthforeveryone.png" /> <Content Include="multifactorauthforeveryone.png" />
<Content Include="LICENSE" /> <Content Include="LICENSE" />
<Content Include="phpunit.xml" />
</ItemGroup> </ItemGroup>
</Project> </Project>
+1 -1
View File
@@ -17,7 +17,7 @@ class HashRNGProvider implements IRNGProvider
$hash = mt_rand(); $hash = mt_rand();
for ($i = 0; $i < $bytecount; $i++) { for ($i = 0; $i < $bytecount; $i++) {
$hash = hash($this->algorithm, $hash.mt_rand(), true); $hash = hash($this->algorithm, $hash.mt_rand(), true);
$result .= $hash[mt_rand(0, sizeof($hash))]; $result .= $hash[mt_rand(0, strlen($hash)-1)];
} }
return $result; return $result;
} }
+1 -1
View File
@@ -11,7 +11,7 @@ class MCryptRNGProvider implements IRNGProvider
} }
public function getRandomBytes($bytecount) { public function getRandomBytes($bytecount) {
$result = mcrypt_create_iv($bytecount, $this->source); $result = @mcrypt_create_iv($bytecount, $this->source);
if ($result === false) if ($result === false)
throw new \RNGException('mcrypt_create_iv returned an invalid value'); throw new \RNGException('mcrypt_create_iv returned an invalid value');
return $result; return $result;
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./lib</directory>
</whitelist>
</filter>
</phpunit>
+7 -5
View File
@@ -125,7 +125,7 @@ class TwoFactorAuthTest extends PHPUnit_Framework_TestCase
$tfa = new TwoFactorAuth('Test', 6, 30, 'sha1'); $tfa = new TwoFactorAuth('Test', 6, 30, 'sha1');
$tfa->ensureCorrectTime(array( $tfa->ensureCorrectTime(array(
new RobThree\Auth\Providers\Time\NTPTimeProvider(), // Uses pool.ntp.org by default new RobThree\Auth\Providers\Time\NTPTimeProvider(), // Uses pool.ntp.org by default
new RobThree\Auth\Providers\Time\NTPTimeProvider('time.windows.com'), //new RobThree\Auth\Providers\Time\NTPTimeProvider('time.google.com'), // Somehow time.google.com and time.windows.com make travis timeout??
new RobThree\Auth\Providers\Time\HttpTimeProvider(), // Uses google.com by default new RobThree\Auth\Providers\Time\HttpTimeProvider(), // Uses google.com by default
new RobThree\Auth\Providers\Time\HttpTimeProvider('https://github.com'), new RobThree\Auth\Providers\Time\HttpTimeProvider('https://github.com'),
new RobThree\Auth\Providers\Time\HttpTimeProvider('https://yahoo.com'), new RobThree\Auth\Providers\Time\HttpTimeProvider('https://yahoo.com'),
@@ -317,10 +317,12 @@ class TwoFactorAuthTest extends PHPUnit_Framework_TestCase
* @requires function mcrypt_create_iv * @requires function mcrypt_create_iv
*/ */
public function testMCryptRNGProvidersReturnExpectedNumberOfBytes() { public function testMCryptRNGProvidersReturnExpectedNumberOfBytes() {
$rng = new \RobThree\Auth\Providers\Rng\MCryptRNGProvider(); if (function_exists('mcrypt_create_iv')) {
foreach ($this->getRngTestLengths() as $l) $rng = new \RobThree\Auth\Providers\Rng\MCryptRNGProvider();
$this->assertEquals($l, strlen($rng->getRandomBytes($l))); foreach ($this->getRngTestLengths() as $l)
$this->assertEquals(true, $rng->isCryptographicallySecure()); $this->assertEquals($l, strlen($rng->getRandomBytes($l)));
$this->assertEquals(true, $rng->isCryptographicallySecure());
}
} }
/** /**