mirror of
https://github.com/RobThree/TwoFactorAuth.git
synced 2026-08-22 02:31:48 +00:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 39db2654a6 | |||
| 4ac2670429 | |||
| 5de91c2837 | |||
| 0ac68f6b86 | |||
| fac4ebd44b | |||
| ad8b7ab3e8 | |||
| d7e8ad8e23 | |||
| b8befc5aff | |||
| 37fbb99ac5 | |||
| ea9b87fe32 | |||
| 4f2364fef4 | |||
| e4ec94e14d | |||
| de210192a7 | |||
| f25b910be9 | |||
| b591c879a1 | |||
| 4408ce7884 |
+5
-8
@@ -1,18 +1,15 @@
|
||||
language: php
|
||||
|
||||
dist: trusty
|
||||
matrix:
|
||||
include:
|
||||
- php: 5.3
|
||||
dist: precise
|
||||
|
||||
php:
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
- hhvm
|
||||
- 7.2
|
||||
|
||||
before_script:
|
||||
- composer install
|
||||
|
||||
script:
|
||||
- if [[ "$TRAVIS_PHP_VERSION" == '5.6' ]]; then phpunit --coverage-text tests ; fi
|
||||
- vendor/bin/phpunit --coverage-text tests
|
||||
@@ -10,7 +10,7 @@ PHP library for [two-factor (or multi-factor) authentication](http://en.wikipedi
|
||||
|
||||
## 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.
|
||||
* [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.
|
||||
|
||||
|
||||
@@ -65,5 +65,6 @@
|
||||
<Content Include="logo.png" />
|
||||
<Content Include="multifactorauthforeveryone.png" />
|
||||
<Content Include="LICENSE" />
|
||||
<Content Include="phpunit.xml" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -17,7 +17,7 @@ class HashRNGProvider implements IRNGProvider
|
||||
$hash = mt_rand();
|
||||
for ($i = 0; $i < $bytecount; $i++) {
|
||||
$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;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ class MCryptRNGProvider implements IRNGProvider
|
||||
}
|
||||
|
||||
public function getRandomBytes($bytecount) {
|
||||
$result = mcrypt_create_iv($bytecount, $this->source);
|
||||
$result = @mcrypt_create_iv($bytecount, $this->source);
|
||||
if ($result === false)
|
||||
throw new \RNGException('mcrypt_create_iv returned an invalid value');
|
||||
return $result;
|
||||
|
||||
+20
@@ -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>
|
||||
@@ -125,7 +125,7 @@ class TwoFactorAuthTest extends PHPUnit_Framework_TestCase
|
||||
$tfa = new TwoFactorAuth('Test', 6, 30, 'sha1');
|
||||
$tfa->ensureCorrectTime(array(
|
||||
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('https://github.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
|
||||
*/
|
||||
public function testMCryptRNGProvidersReturnExpectedNumberOfBytes() {
|
||||
$rng = new \RobThree\Auth\Providers\Rng\MCryptRNGProvider();
|
||||
foreach ($this->getRngTestLengths() as $l)
|
||||
$this->assertEquals($l, strlen($rng->getRandomBytes($l)));
|
||||
$this->assertEquals(true, $rng->isCryptographicallySecure());
|
||||
if (function_exists('mcrypt_create_iv')) {
|
||||
$rng = new \RobThree\Auth\Providers\Rng\MCryptRNGProvider();
|
||||
foreach ($this->getRngTestLengths() as $l)
|
||||
$this->assertEquals($l, strlen($rng->getRandomBytes($l)));
|
||||
$this->assertEquals(true, $rng->isCryptographicallySecure());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user