diff --git a/.travis.yml b/.travis.yml index 8221520..65fc4f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,40 +2,14 @@ language: php matrix: include: - - os: linux - dist: precise - sudo: false - php: 5.3 - - os: linux - dist: precise - sudo: false - php: 5.4 - - os: linux - dist: precise - sudo: false - php: 5.5 - - os: linux - dist: precise - sudo: false - php: 5.6 - env: - - TEST_COVERAGE=true - - os: linux - dist: trusty - sudo: false - php: 7 - - os: linux - dist: trusty - sudo: false - php: 7.1 - os: linux dist: trusty sudo: false - php: hhvm + php: 7.2 - os: linux dist: trusty sudo: false - php: nightly + php: 7.3 before_script: - composer self-update diff --git a/README.md b/README.md index cee23a6..c5c2cd6 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Note that the purpose of this package is only to authenticate user credentials. ### Installation -This library requires PHP 5.5 or later, and has no userland dependencies. (As a special consideration, this library is compatible with PHP 5.3 and 5.4 when the [ircmaxell/password-compat](https://github.com/ircmaxell/password_compat) package is installed.) +This library requires PHP 7.2 or later, and has no userland dependencies. It is installable and autoloadable via Composer as [aura/auth](https://packagist.org/packages/aura/auth). diff --git a/composer.json b/composer.json index 5c8c835..4b4cf27 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=5.3.0" + "php": ">=7.2.0" }, "autoload": { "psr-4": { @@ -32,9 +32,12 @@ } } }, + + "minimum-stability": "dev", "require-dev": { - "aura/di": "~2.0", - "phpunit/phpunit": "~5.7 || ~4.8" + "acclimate/container": "^2", + "aura/di": "~4.0", + "phpunit/phpunit": "~7" }, "autoload-dev": { "psr-4": { @@ -44,7 +47,6 @@ }, "suggest": { "ext/ldap": "For LDAP integration.", - "ext/imap": "For IMAP/POP/NNTP integration.", - "ircmaxell/password-compat": "Provides password_verify() for PHP versions earlier than 5.5" + "ext/imap": "For IMAP/POP/NNTP integration." } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8646377..e96da97 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,10 +1,10 @@ - + ./tests - + diff --git a/src/AuthFactory.php b/src/AuthFactory.php index 72e1e32..d6f6a1f 100644 --- a/src/AuthFactory.php +++ b/src/AuthFactory.php @@ -134,8 +134,8 @@ public function newLogoutService(AdapterInterface $adapter = null) */ public function newResumeService( AdapterInterface $adapter = null, - $idle_ttl = 1440, - $expire_ttl = 14400 + $idle_ttl = 3600, // 1 hour + $expire_ttl = 86400 // 24 hours ) { $adapter = $this->fixAdapter($adapter); diff --git a/src/Session/Timer.php b/src/Session/Timer.php index 3ac9444..c454e8f 100644 --- a/src/Session/Timer.php +++ b/src/Session/Timer.php @@ -43,7 +43,7 @@ class Timer * @var int * */ - protected $idle_ttl = 1440; + protected $idle_ttl = 3600; // 1 hour /** * @@ -52,7 +52,7 @@ class Timer * @var int * */ - protected $expire_ttl = 14400; + protected $expire_ttl = 86400; // 24 hours /** * @@ -68,10 +68,10 @@ class Timer * */ public function __construct( - $ini_gc_maxlifetime = 1440, + $ini_gc_maxlifetime = 86401, // 24 hours plus 1 second $ini_cookie_lifetime = 0, - $idle_ttl = 1440, - $expire_ttl = 14400 + $idle_ttl = 3600, // 1 hour + $expire_ttl = 86400 // 24 hours ) { $this->ini_gc_maxlifetime = $ini_gc_maxlifetime; $this->ini_cookie_lifetime = $ini_cookie_lifetime; @@ -94,7 +94,7 @@ public function __construct( public function setIdleTtl($idle_ttl) { if ($this->ini_gc_maxlifetime < $idle_ttl) { - throw new Exception("session.gc_maxlifetime $this->ini_gc_maxlifetime less than idle time $idle_ttl"); + throw new Exception("session.gc_maxlifetime {$this->ini_gc_maxlifetime} less than idle time $idle_ttl"); } $this->idle_ttl = $idle_ttl; } diff --git a/tests/Adapter/HtpasswdAdapterTest.php b/tests/Adapter/HtpasswdAdapterTest.php index 8dd7467..95752e9 100644 --- a/tests/Adapter/HtpasswdAdapterTest.php +++ b/tests/Adapter/HtpasswdAdapterTest.php @@ -3,7 +3,7 @@ use Aura\Auth\Verifier\HtpasswdVerifier; -class HtpasswdAdapterTest extends \PHPUnit_Framework_TestCase +class HtpasswdAdapterTest extends \PHPUnit\Framework\TestCase { protected $adapter; @@ -21,7 +21,7 @@ protected function setAdapter($file) public function testLogin_fileNotReadable() { $this->setAdapter('no-such-file'); - $this->setExpectedException('Aura\Auth\Exception\FileNotReadable'); + $this->expectException('Aura\Auth\Exception\FileNotReadable'); $this->adapter->login(array( 'username' => 'boshag', 'password' => '123456', @@ -40,13 +40,13 @@ public function testLogin_success() public function testLogin_usernameMissing() { - $this->setExpectedException('Aura\Auth\Exception\UsernameMissing'); + $this->expectException('Aura\Auth\Exception\UsernameMissing'); $this->adapter->login(array()); } public function testLogin_passwordMissing() { - $this->setExpectedException('Aura\Auth\Exception\PasswordMissing'); + $this->expectException('Aura\Auth\Exception\PasswordMissing'); $this->adapter->login(array( 'username' => 'boshag', )); @@ -54,7 +54,7 @@ public function testLogin_passwordMissing() public function testLogin_usernameNotFound() { - $this->setExpectedException('Aura\Auth\Exception\UsernameNotFound'); + $this->expectException('Aura\Auth\Exception\UsernameNotFound'); $this->adapter->login(array( 'username' => 'nouser', 'password' => 'nopass', @@ -63,10 +63,10 @@ public function testLogin_usernameNotFound() public function testLogin_passwordIncorrect() { - $this->setExpectedException('Aura\Auth\Exception\PasswordIncorrect'); + $this->expectException('Aura\Auth\Exception\PasswordIncorrect'); $this->adapter->login(array( 'username' => 'boshag', 'password' => '------', )); } -} \ No newline at end of file +} diff --git a/tests/Adapter/ImapAdapterTest.php b/tests/Adapter/ImapAdapterTest.php index 1084fa7..a895b78 100644 --- a/tests/Adapter/ImapAdapterTest.php +++ b/tests/Adapter/ImapAdapterTest.php @@ -3,7 +3,7 @@ use Aura\Auth\Phpfunc; -class ImapAdapterTest extends \PHPUnit_Framework_TestCase +class ImapAdapterTest extends \PHPUnit\Framework\TestCase { protected $phpfunc; @@ -63,7 +63,7 @@ public function testLogin_connectionFailed() ->with('{mailbox.example.com:143/imap/secure}') ->will($this->returnValue(false)); - $this->setExpectedException('Aura\Auth\Exception\ConnectionFailed'); + $this->expectException('Aura\Auth\Exception\ConnectionFailed'); $this->adapter->login(array( 'username' => 'someusername', 'password' => 'secretpassword' diff --git a/tests/Adapter/LdapAdapterTest.php b/tests/Adapter/LdapAdapterTest.php index 15e19c8..f0fb5de 100644 --- a/tests/Adapter/LdapAdapterTest.php +++ b/tests/Adapter/LdapAdapterTest.php @@ -3,7 +3,7 @@ use Aura\Auth\Phpfunc; -class LdapAdapterTest extends \PHPUnit_Framework_TestCase +class LdapAdapterTest extends \PHPUnit\Framework\TestCase { protected $adapter; @@ -84,7 +84,7 @@ public function testLogin_connectionFailed() ->with('ldaps://ldap.example.com:636') ->will($this->returnValue(false)); - $this->setExpectedException('Aura\Auth\Exception\ConnectionFailed'); + $this->expectException('Aura\Auth\Exception\ConnectionFailed'); $this->adapter->login($input); } @@ -115,7 +115,7 @@ public function testLogin_bindFailed() ->method('ldap_unbind') ->will($this->returnValue(true)); - $this->setExpectedException('Aura\Auth\Exception\BindFailed'); + $this->expectException('Aura\Auth\Exception\BindFailed'); $this->adapter->login(array( 'username' => 'someusername', 'password' => 'secretpassword' diff --git a/tests/Adapter/NullAdapterTest.php b/tests/Adapter/NullAdapterTest.php index c278167..de891a2 100644 --- a/tests/Adapter/NullAdapterTest.php +++ b/tests/Adapter/NullAdapterTest.php @@ -1,7 +1,7 @@ setExpectedException('Aura\Auth\Exception\UsernameColumnNotSpecified'); + $this->expectException('Aura\Auth\Exception\UsernameColumnNotSpecified'); $this->adapter = new PdoAdapter( $this->pdo, new PasswordVerifier('md5'), @@ -84,7 +84,7 @@ public function test_usernameColumnNotSpecified() public function test_passwordColumnNotSpecified() { - $this->setExpectedException('Aura\Auth\Exception\PasswordColumnNotSpecified'); + $this->expectException('Aura\Auth\Exception\PasswordColumnNotSpecified'); $this->adapter = new PdoAdapter( $this->pdo, new PasswordVerifier('md5'), @@ -106,13 +106,13 @@ public function testLogin() public function testLogin_usernameMissing() { - $this->setExpectedException('Aura\Auth\Exception\UsernameMissing'); + $this->expectException('Aura\Auth\Exception\UsernameMissing'); $this->adapter->login(array()); } public function testLogin_passwordMissing() { - $this->setExpectedException('Aura\Auth\Exception\PasswordMissing'); + $this->expectException('Aura\Auth\Exception\PasswordMissing'); $this->adapter->login(array( 'username' => 'boshag', )); @@ -120,7 +120,7 @@ public function testLogin_passwordMissing() public function testLogin_usernameNotFound() { - $this->setExpectedException('Aura\Auth\Exception\UsernameNotFound'); + $this->expectException('Aura\Auth\Exception\UsernameNotFound'); $this->adapter->login(array( 'username' => 'missing', 'password' => '------', @@ -129,7 +129,7 @@ public function testLogin_usernameNotFound() public function testLogin_passwordIncorrect() { - $this->setExpectedException('Aura\Auth\Exception\PasswordIncorrect'); + $this->expectException('Aura\Auth\Exception\PasswordIncorrect'); $this->adapter->login(array( 'username' => 'boshag', 'password' => '------', @@ -138,7 +138,7 @@ public function testLogin_passwordIncorrect() public function testLogin_multipleMatches() { - $this->setExpectedException('Aura\Auth\Exception\MultipleMatches'); + $this->expectException('Aura\Auth\Exception\MultipleMatches'); $this->adapter->login(array( 'username' => 'repeat', 'password' => '234567', diff --git a/tests/AuthFactoryTest.php b/tests/AuthFactoryTest.php index db483a1..017925d 100644 --- a/tests/AuthFactoryTest.php +++ b/tests/AuthFactoryTest.php @@ -6,7 +6,7 @@ use Aura\Auth\Session\Segment; use Aura\Auth\Verifier\FakeVerifier; -class AuthFactoryTest extends \PHPUnit_Framework_TestCase +class AuthFactoryTest extends \PHPUnit\Framework\TestCase { protected $factory; diff --git a/tests/AuthTest.php b/tests/AuthTest.php index 964a042..f14e2ca 100644 --- a/tests/AuthTest.php +++ b/tests/AuthTest.php @@ -4,7 +4,7 @@ use Aura\Auth\Session\FakeSegment; use Aura\Auth\Status; -class AuthTest extends \PHPUnit_Framework_TestCase +class AuthTest extends \PHPUnit\Framework\TestCase { protected $auth; diff --git a/tests/ContainerTest.php b/tests/ContainerTest.php index 811b9c0..9ff9ff8 100644 --- a/tests/ContainerTest.php +++ b/tests/ContainerTest.php @@ -1,7 +1,7 @@ segment = new FakeSegment; $this->session = new FakeSession; $this->adapter = new FakeAdapter; - $this->timer = new Timer(1440, 14400); + $this->timer = new Timer(3600, 86400); $this->auth = new Auth($this->segment); @@ -79,7 +79,7 @@ public function testResume_logoutIdle() $this->login_service->forceLogin($this->auth, 'boshag'); $this->assertTrue($this->auth->isValid()); - $this->auth->setLastActive(time() - 1441); + $this->auth->setLastActive(time() - 3601); $this->resume_service->resume($this->auth); $this->assertTrue($this->auth->isIdle()); @@ -92,7 +92,7 @@ public function testResume_logoutExpired() $this->login_service->forceLogin($this->auth, 'boshag'); $this->assertTrue($this->auth->isValid()); - $this->auth->setFirstActive(time() - 14441); + $this->auth->setFirstActive(time() - 86401); $this->resume_service->resume($this->auth); $this->assertTrue($this->auth->isExpired()); diff --git a/tests/Session/NullSegmentTest.php b/tests/Session/NullSegmentTest.php index 1ee63f2..55e12c2 100644 --- a/tests/Session/NullSegmentTest.php +++ b/tests/Session/NullSegmentTest.php @@ -1,7 +1,7 @@ timer = new Timer(1440, 14400); + $this->timer = new Timer(3600, 86400); } public function testHasExpired() { $this->assertFalse($this->timer->hasExpired(time())); - $this->assertTrue($this->timer->hasExpired(time() - 14441)); + $this->assertTrue($this->timer->hasExpired(time() - 86401)); } public function testHasIdled() { $this->assertFalse($this->timer->hasIdled(time())); - $this->assertTrue($this->timer->hasIdled(time() - 1441)); + $this->assertTrue($this->timer->hasIdled(time() - 3601)); } public function testGetTimeoutStatus() { $actual = $this->timer->getTimeoutStatus( - time() - 14441, + time() - 86401, time() ); $this->assertSame(Status::EXPIRED, $actual); $actual = $this->timer->getTimeoutStatus( - time() - 1442, - time() - 1441 + time() - 3602, + time() - 3601 ); $this->assertSame(Status::IDLE, $actual); @@ -47,13 +47,13 @@ public function testGetTimeoutStatus() public function testSetIdleTtl_bad() { - $this->setExpectedException('Aura\Auth\Exception'); - $this->timer->setIdleTtl(1441); + $this->expectException('Aura\Auth\Exception'); + $this->timer->setIdleTtl(3601); } public function testSetExpireTtl_bad() { - $this->setExpectedException('Aura\Auth\Exception'); - $this->timer->setExpireTtl(14441); + $this->expectException('Aura\Auth\Exception'); + $this->timer->setExpireTtl(86401); } } diff --git a/tests/Verifier/HtpasswdVerifierTest.php b/tests/Verifier/HtpasswdVerifierTest.php index 36654cc..e019853 100644 --- a/tests/Verifier/HtpasswdVerifierTest.php +++ b/tests/Verifier/HtpasswdVerifierTest.php @@ -1,7 +1,7 @@