From bce7ccc7434cd56a9aa25cde953aba0c0546e38b Mon Sep 17 00:00:00 2001 From: Rainer Volz Date: Thu, 1 Oct 2015 10:50:34 +0200 Subject: [PATCH] Added cookie path handling via Aura\Session to enable multiple instances on the same server with login, fixes #173. By default session cookies used the "/" path. With multiple instances on the same server this meant that a session was valid for all instances on this server. The new session handling uses the instance path, e.g. .../bbs, to qualify a session cookie for only this instance. --- ChangeLog | 1 + composer.json | 2 +- composer.lock | 19 ++-- lib/BicBucStriim/app_constants.php | 7 +- lib/BicBucStriim/login_middleware.php | 12 ++- lib/BicBucStriim/segment.php | 22 +++++ lib/BicBucStriim/segment_factory.php | 31 ++++++ lib/BicBucStriim/session.php | 15 +++ lib/BicBucStriim/session_factory.php | 44 +++++++++ vendor/aura/auth/README.md | 97 +++++++++++------- vendor/aura/auth/composer.json | 75 +++++++------- .../auth/src/Adapter/AdapterInterface.php | 3 +- .../aura/auth/src/Adapter/HtpasswdAdapter.php | 4 +- vendor/aura/auth/src/Adapter/ImapAdapter.php | 5 +- vendor/aura/auth/src/Adapter/LdapAdapter.php | 35 ++++--- vendor/aura/auth/src/Adapter/PdoAdapter.php | 9 +- vendor/aura/auth/src/Auth.php | 3 +- vendor/aura/auth/src/AuthFactory.php | 24 +++-- .../auth/src/Exception/FileNotReadable.php | 14 +-- vendor/aura/auth/src/Service/LoginService.php | 8 +- .../aura/auth/src/Service/LogoutService.php | 3 +- .../aura/auth/src/Service/ResumeService.php | 5 +- vendor/aura/auth/src/Session/Segment.php | 2 +- vendor/aura/auth/src/Session/Timer.php | 7 +- .../auth/src/Verifier/HtpasswdVerifier.php | 2 +- .../aura/auth/tests/container/bootstrap.php | 2 +- .../tests/unit/src/Adapter/PdoAdapterTest.php | 6 +- .../auth/tests/unit/src/AuthFactoryTest.php | 10 +- .../tests/unit/src/Session/FakeSession.php | 2 +- .../src/Verifier/HtpasswdVerifierTest.php | 2 +- .../src/Verifier/PasswordVerifierTest.php | 2 +- vendor/composer/installed.json | 99 +++++++++---------- 32 files changed, 354 insertions(+), 218 deletions(-) create mode 100644 lib/BicBucStriim/segment.php create mode 100644 lib/BicBucStriim/segment_factory.php create mode 100644 lib/BicBucStriim/session.php create mode 100644 lib/BicBucStriim/session_factory.php diff --git a/ChangeLog b/ChangeLog index cd48ff07..2cad7799 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ * Added admin configuration to specify the kind of date used for sorting (timestamp, pubdate or modified) * Updated layout * Replaced outdated auth library Slim\Strong with Aura\Auth +* Added Aura\Session library to handle sessions properly, #173 2015-09-11 Version 1.2.6 * Security changes: protection against SQL injection, see #175 diff --git a/composer.json b/composer.json index 8b39d3ea..7e6efc92 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "slim/views": "0.1.2", "swiftmailer/swiftmailer": "5.0.1", "twig/twig": "1.16.0", - "aura/auth": "2.0.0-beta2", + "aura/auth": "2.x-dev", "aura/session": "2.0.1", "ircmaxell/password-compat": "v1.0.4" }, diff --git a/composer.lock b/composer.lock index e4ab7750..dc0a7c42 100644 --- a/composer.lock +++ b/composer.lock @@ -4,21 +4,21 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "67bea8910cd25f56f76038dcc170e4d7", - "content-hash": "ca381df8c24e62b6f5b9377d8d13e4bc", + "hash": "6d43c91e3b552da6e584c37d7b7d1a89", + "content-hash": "86c031903df2d5ad9b4f74f9be7cf682", "packages": [ { "name": "aura/auth", - "version": "2.0.0-beta2", + "version": "2.x-dev", "source": { "type": "git", "url": "https://github.com/auraphp/Aura.Auth.git", - "reference": "8010400aa090f52e9c4056399c018c4bb96d7fc1" + "reference": "f9691d48860b163641ddf2a1e616d035ff8f885b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/auraphp/Aura.Auth/zipball/8010400aa090f52e9c4056399c018c4bb96d7fc1", - "reference": "8010400aa090f52e9c4056399c018c4bb96d7fc1", + "url": "https://api.github.com/repos/auraphp/Aura.Auth/zipball/f9691d48860b163641ddf2a1e616d035ff8f885b", + "reference": "f9691d48860b163641ddf2a1e616d035ff8f885b", "shasum": "" }, "require": { @@ -36,9 +36,6 @@ "config": { "common": "Aura\\Auth\\_Config\\Common" } - }, - "branch-alias": { - "dev-develop-2": "2.0.x-dev" } }, "autoload": { @@ -64,7 +61,7 @@ "auth", "authenticate" ], - "time": "2014-11-07 15:41:31" + "time": "2015-08-08 09:48:54" }, { "name": "aura/session", @@ -510,7 +507,7 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": { - "aura/auth": 10 + "aura/auth": 20 }, "prefer-stable": false, "prefer-lowest": false, diff --git a/lib/BicBucStriim/app_constants.php b/lib/BicBucStriim/app_constants.php index da2da710..0bd316d8 100644 --- a/lib/BicBucStriim/app_constants.php +++ b/lib/BicBucStriim/app_constants.php @@ -2,10 +2,11 @@ /** * BicBucStriim * - * Copyright 2012-2013 Rainer Volz + * Copyright 2012-2015 Rainer Volz * Licensed under MIT License, see LICENSE - * - */ + * + */ + # Current DB schema version const DB_SCHEMA_VERSION = 3; diff --git a/lib/BicBucStriim/login_middleware.php b/lib/BicBucStriim/login_middleware.php index c32f3963..c81f7afc 100644 --- a/lib/BicBucStriim/login_middleware.php +++ b/lib/BicBucStriim/login_middleware.php @@ -9,6 +9,9 @@ require 'vendor/autoload.php'; require_once 'lib/BicBucStriim/bicbucstriim.php'; +require_once 'lib/BicBucStriim/session_factory.php'; +require_once 'lib/BicBucStriim/segment_factory.php'; +require_once 'lib/BicBucStriim/session.php'; use Aura\Auth; class LoginMiddleware extends \Slim\Middleware { @@ -42,8 +45,7 @@ public function authBeforeDispatch() { $resource = $request->getResourceUri(); $accept = $request->headers('ACCEPT'); $app->getLog()->debug('login resource: '.$resource); - $app->getLog()->debug('login accept: '.var_export($accept,true)); - if ($globalSettings[LOGIN_REQUIRED] === 1) { + if ($globalSettings[LOGIN_REQUIRED] === 1) { if (!$this->is_static_resource($resource) && !$this->is_authorized()) { if ($resource === '/login/') { // special case login page @@ -104,7 +106,10 @@ protected function is_static_resource($resource) { protected function is_authorized() { $app = $this->app; $req = $app->request; - $auth_factory = new \Aura\Auth\AuthFactory($_COOKIE); + $session_factory = new \BicBucStriim\SessionFactory(); + $session = $session_factory->newInstance($_COOKIE); + $session->setCookieParams(array('path' => $app->request->getRootUri())); + $auth_factory = new \Aura\Auth\AuthFactory($_COOKIE, $session); $app->auth = $auth_factory->newInstance(); $hash = new \Aura\Auth\Verifier\PasswordVerifier(PASSWORD_BCRYPT); $cols = array('username', 'password', 'id', 'email', 'role', 'languages', 'tags'); @@ -113,6 +118,7 @@ protected function is_authorized() { $app->logout_service = $auth_factory->newLogoutService($pdo_adapter); $resume_service = $auth_factory->newResumeService($pdo_adapter); $resume_service->resume($app->auth); + $app->getLog()->debug("after resume: " . $app->auth->getStatus()); if ($app->auth->isValid()) { // already logged in return true; diff --git a/lib/BicBucStriim/segment.php b/lib/BicBucStriim/segment.php new file mode 100644 index 00000000..62200d85 --- /dev/null +++ b/lib/BicBucStriim/segment.php @@ -0,0 +1,22 @@ +provider = $provider; } @@ -521,22 +523,13 @@ class LeagueOAuth2Adapter implements AdapterInterface array('code' => $input['code']) ); - $details = $this->provider->getUserDetails($token); + $details = $this->provider->getResourceOwner($token); $data = [ - 'uid' => $details->__get('uid'), - 'nickname' => $details->__get('nickname'), - 'name' => $details->__get('name'), - 'firstName' => $details->__get('firstName'), - 'lastName' => $details->__get('lastName'), - 'email' => $details->__get('email'), - 'location' => $details->__get('location'), - 'description' => $details->__get('description'), - 'imageUrl' => $details->__get('imageUrl'), - 'urls' => $details->__get('urls'), + 'name' => $details->getName(), + 'email' => $details->getEmail(), ]; $data['token'] = $token; - $username = $data['nickname']; - unset($data['nickname']); + $username = $data['email']; return [$username, $data]; } @@ -544,7 +537,7 @@ class LeagueOAuth2Adapter implements AdapterInterface * @param Auth $auth * Logout method is required to fulfill the contract with AdapterInterface */ - public function logout(Auth $auth) + public function logout(Auth $auth, $status = Status::ANON) { //nothing to do here } @@ -576,27 +569,32 @@ look like. newInstance(); + +$github_provider = new Github(array( 'clientId' => 'xxxxxxxxxxxxxxxx', 'clientSecret' => 'xxxxxxxxxxxxxxxxxxxx', 'redirectUri' => 'http://aura.auth.dev/' )); if (!isset($_GET['code'])) { - header('Location: ' . $githubProvider->getAuthorizationUrl()); + header('Location: ' . $github_provider->getAuthorizationUrl()); exit; } else { - $auraAdapter = new LeagueOAuth2Adapter($githubProvider); + $oauth_adapter = new LeagueOAuth2Adapter($github_provider); + $login_service = $auth_factory->newLoginService($oauth_adapter); try { // array is the username and an array of info and indicates successful // login - $data = $githubAdapter->login($_GET); + $data = $login_service->login($auth, $_GET); } catch (Exception $e) { // handle the exception } @@ -646,40 +644,70 @@ switch (true) { #### Logging In -This is an example of the code needed to effect a login. Note that the `echo` statements are intended to explain the different resulting states of the `login()` call, and may be replaced by whatever logic you feel is appropriate. +This is an example of the code needed to effect a login. Note that the `echo` and `$log` statements are intended to explain the different resulting states of the `login()` call, and may be replaced by whatever logic you feel is appropriate; in particular, you should probably not expose the exact nature of the failure, to help mitigate brute-force attempts. ```php newInstance(); $login_service = $auth_factory->newLoginService(...); try { + $login_service->login($auth, array( 'username' => $_POST['username'], 'password' => $_POST['password'], ); echo "You are now logged into a new session."; + } catch (\Aura\Auth\Exception\UsernameMissing $e) { - echo "The 'username' field is missing or empty."; + + $log->notice("The 'username' field is missing or empty."); + throw new InvalidLoginException(); + } catch (\Aura\Auth\Exception\PasswordMissing $e) { - echo "The 'password' field is missing or empty."; + + $log->notice("The 'password' field is missing or empty."); + throw new InvalidLoginException(); + } catch (\Aura\Auth\Exception\UsernameNotFound $e) { - echo "The username you entered was not found."; + + $log->warning("The username you entered was not found."); + throw new InvalidLoginException(); + } catch (\Aura\Auth\Exception\MultipleMatches $e) { - echo "There is more than one account with that username."; + + $log->warning("There is more than one account with that username."); + throw new InvalidLoginException(); + } catch (\Aura\Auth\Exception\PasswordIncorrect $e) { - echo "The password you entered was incorrect."; + + $log->notice("The password you entered was incorrect."); + throw new InvalidLoginException(); + } catch (\Aura\Auth\Exception\ConnectionFailed $e) { - echo "Cound not connect to IMAP or LDAP server."; - echo "This could be because the username or password was wrong,"; - echo "or because the the connect operation itself failed in some way. "; - echo $e->getMessage(); + + $log->notice("Cound not connect to IMAP or LDAP server."); + $log->info("This could be because the username or password was wrong,"); + $log->info("or because the the connect operation itself failed in some way. "); + $log->info($e->getMessage()); + throw new InvalidLoginException(); + } catch (\Aura\Auth\Exception\BindFailed $e) { - echo "Cound not bind to LDAP server."; - echo "This could be because the username or password was wrong,"; - echo "or because the the bind operations itself failed in some way. "; - echo $e->getMessage(); + + $log->notice("Cound not bind to LDAP server."); + $log->info("This could be because the username or password was wrong,"); + $log->info("or because the the bind operation itself failed in some way. "); + $log->info($e->getMessage()); + throw new InvalidLoginException(); + +} catch (InvalidLoginException $e) { + + echo "Invalid login details. Please try again."; + } ?> ``` @@ -895,4 +923,3 @@ $di->params['Aura\Auth\Adapter\PdoAdapter'] = array( ); ?> ``` - diff --git a/vendor/aura/auth/composer.json b/vendor/aura/auth/composer.json index 3c4e8a7d..90d1c203 100644 --- a/vendor/aura/auth/composer.json +++ b/vendor/aura/auth/composer.json @@ -1,43 +1,40 @@ { - "name": "aura/auth", - "type": "library", - "description": "Aura Auth provides a unified interface to authenticate a user with local or remote authentication systems.", - "keywords": [ - "auth", - "authenticate", - "authentication" - ], - "homepage": "https://github.com/auraphp/Aura.Auth", - "license": "BSD-2-Clause", - "authors": [ - { - "name": "Aura.Auth Contributors", - "homepage": "https://github.com/auraphp/Aura.Auth/contributors" - } - ], - "require": { - "php": ">=5.3.0" - }, - "autoload": { - "psr-4": { - "Aura\\Auth\\": "src/", - "Aura\\Auth\\_Config\\": "config/" - } - }, - "extra": { - "aura": { - "type": "library", - "config": { - "common": "Aura\\Auth\\_Config\\Common" - } + "name": "aura/auth", + "type": "library", + "description": "Aura Auth provides a unified interface to authenticate a user with local or remote authentication systems.", + "keywords": [ + "auth", + "authenticate", + "authentication" + ], + "homepage": "https://github.com/auraphp/Aura.Auth", + "license": "BSD-2-Clause", + "authors": [ + { + "name": "Aura.Auth Contributors", + "homepage": "https://github.com/auraphp/Aura.Auth/contributors" + } + ], + "require": { + "php": ">=5.3.0" + }, + "autoload": { + "psr-4": { + "Aura\\Auth\\": "src/", + "Aura\\Auth\\_Config\\": "config/" + } + }, + "extra": { + "aura": { + "type": "library", + "config": { + "common": "Aura\\Auth\\_Config\\Common" + } + } }, - "branch-alias": { - "dev-develop-2": "2.0.x-dev" + "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" } - }, - "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" - } } diff --git a/vendor/aura/auth/src/Adapter/AdapterInterface.php b/vendor/aura/auth/src/Adapter/AdapterInterface.php index ce3a63fb..f24d13f2 100644 --- a/vendor/aura/auth/src/Adapter/AdapterInterface.php +++ b/vendor/aura/auth/src/Adapter/AdapterInterface.php @@ -11,6 +11,7 @@ namespace Aura\Auth\Adapter; use Aura\Auth\Auth; +use Aura\Auth\Status; /** * @@ -36,7 +37,7 @@ public function login(array $input); * * Handle logout logic against the storage backend. * - * @param Auth $auth The authentication obbject to be logged out. + * @param Auth $auth The authentication object to be logged out. * * @param string $status The new authentication status after logout. * diff --git a/vendor/aura/auth/src/Adapter/HtpasswdAdapter.php b/vendor/aura/auth/src/Adapter/HtpasswdAdapter.php index 8b22cf15..a073340c 100755 --- a/vendor/aura/auth/src/Adapter/HtpasswdAdapter.php +++ b/vendor/aura/auth/src/Adapter/HtpasswdAdapter.php @@ -114,7 +114,7 @@ protected function fetchHashedPassword($username) { // force the full, real path to the file $real = realpath($this->file); - if (!$real) { + if (! $real) { throw new Exception\FileNotReadable($this->file); } @@ -157,7 +157,7 @@ protected function fetchHashedPassword($username) */ protected function verify($password, $hashvalue) { - if (!$this->verifier->verify($password, $hashvalue)) { + if (! $this->verifier->verify($password, $hashvalue)) { throw new Exception\PasswordIncorrect; } } diff --git a/vendor/aura/auth/src/Adapter/ImapAdapter.php b/vendor/aura/auth/src/Adapter/ImapAdapter.php index 0bfd3e15..538aa76f 100755 --- a/vendor/aura/auth/src/Adapter/ImapAdapter.php +++ b/vendor/aura/auth/src/Adapter/ImapAdapter.php @@ -89,8 +89,7 @@ public function __construct( $options = 0, $retries = 1, array $params = null - ) - { + ) { $this->phpfunc = $phpfunc; $this->mailbox = $mailbox; $this->options = $options; @@ -125,7 +124,7 @@ public function login(array $input) $this->params ); - if (!$conn) { + if (! $conn) { throw new Exception\ConnectionFailed($this->mailbox); } diff --git a/vendor/aura/auth/src/Adapter/LdapAdapter.php b/vendor/aura/auth/src/Adapter/LdapAdapter.php index 085114ad..c43f9332 100755 --- a/vendor/aura/auth/src/Adapter/LdapAdapter.php +++ b/vendor/aura/auth/src/Adapter/LdapAdapter.php @@ -76,8 +76,7 @@ public function __construct( $server, $dnformat, array $options = array() - ) - { + ) { $this->phpfunc = $phpfunc; $this->server = $server; $this->dnformat = $dnformat; @@ -117,7 +116,7 @@ public function login(array $input) protected function connect() { $conn = $this->phpfunc->ldap_connect($this->server); - if (!$conn) { + if (! $conn) { throw new Exception\ConnectionFailed($this->server); } @@ -147,10 +146,10 @@ protected function bind($conn, $username, $password) $bind_rdn = sprintf($this->dnformat, $username); $bound = $this->phpfunc->ldap_bind($conn, $bind_rdn, $password); - if (!$bound) { + if (! $bound) { $error = $this->phpfunc->ldap_errno($conn) - . ': ' - . $this->phpfunc->ldap_error($conn); + . ': ' + . $this->phpfunc->ldap_error($conn); $this->phpfunc->ldap_close($conn); throw new Exception\BindFailed($error); } @@ -175,18 +174,18 @@ protected function escape($str) { return strtr($str, array( '\\' => '\\\\', - '&' => '\\&', - '!' => '\\!', - '|' => '\\|', - '=' => '\\=', - '<' => '\\<', - '>' => '\\>', - ',' => '\\,', - '+' => '\\+', - '-' => '\\-', - '"' => '\\"', - "'" => "\\'", - ';' => '\\;', + '&' => '\\&', + '!' => '\\!', + '|' => '\\|', + '=' => '\\=', + '<' => '\\<', + '>' => '\\>', + ',' => '\\,', + '+' => '\\+', + '-' => '\\-', + '"' => '\\"', + "'" => "\\'", + ';' => '\\;', )); } } diff --git a/vendor/aura/auth/src/Adapter/PdoAdapter.php b/vendor/aura/auth/src/Adapter/PdoAdapter.php index 0c90357a..76a1d3b0 100755 --- a/vendor/aura/auth/src/Adapter/PdoAdapter.php +++ b/vendor/aura/auth/src/Adapter/PdoAdapter.php @@ -89,8 +89,7 @@ public function __construct( array $cols, $from, $where = null - ) - { + ) { $this->pdo = $pdo; $this->verifier = $verifier; $this->setCols($cols); @@ -113,10 +112,10 @@ public function __construct( */ protected function setCols($cols) { - if (!isset($cols[0]) || trim($cols[0] == '')) { + if (! isset($cols[0]) || trim($cols[0] == '')) { throw new Exception\UsernameColumnNotSpecified; } - if (!isset($cols[1]) || trim($cols[1] == '')) { + if (! isset($cols[1]) || trim($cols[1] == '')) { throw new Exception\PasswordColumnNotSpecified; } $this->cols = $cols; @@ -282,7 +281,7 @@ protected function verify($input, $data) $data ); - if (!$verified) { + if (! $verified) { throw new Exception\PasswordIncorrect; } diff --git a/vendor/aura/auth/src/Auth.php b/vendor/aura/auth/src/Auth.php index b34b4c54..50f410a0 100644 --- a/vendor/aura/auth/src/Auth.php +++ b/vendor/aura/auth/src/Auth.php @@ -69,8 +69,7 @@ public function set( $last_active, $username, array $userdata - ) - { + ) { $this->setStatus($status); $this->setFirstActive($first_active); $this->setLastActive($last_active); diff --git a/vendor/aura/auth/src/AuthFactory.php b/vendor/aura/auth/src/AuthFactory.php index c8296b78..c8f112e6 100644 --- a/vendor/aura/auth/src/AuthFactory.php +++ b/vendor/aura/auth/src/AuthFactory.php @@ -13,6 +13,8 @@ use Aura\Auth\Adapter; use Aura\Auth\Service; use Aura\Auth\Session; +use Aura\Auth\Session\SessionInterface; +use Aura\Auth\Session\SegmentInterface; use Aura\Auth\Verifier; use Aura\Auth\Adapter\AdapterInterface; use PDO; @@ -24,6 +26,7 @@ * @package Aura.Auth * */ + class AuthFactory { /** @@ -59,15 +62,14 @@ public function __construct( array $cookie, SessionInterface $session = null, SegmentInterface $segment = null - ) - { + ) { $this->session = $session; - if (!$this->session) { + if (! $this->session) { $this->session = new Session\Session($cookie); } $this->segment = $segment; - if (!$this->segment) { + if (! $this->segment) { $this->segment = new Session\Segment; } } @@ -136,8 +138,7 @@ public function newResumeService( AdapterInterface $adapter = null, $idle_ttl = 1440, $expire_ttl = 14400 - ) - { + ) { $adapter = $this->fixAdapter($adapter); @@ -204,8 +205,7 @@ public function newPdoAdapter( array $cols, $from, $where = null - ) - { + ) { if (is_object($verifier_spec)) { $verifier = $verifier_spec; } else { @@ -259,8 +259,7 @@ public function newImapAdapter( $options = 0, $retries = 1, array $params = null - ) - { + ) { return new Adapter\ImapAdapter( new Phpfunc, $mailbox, @@ -276,7 +275,7 @@ public function newImapAdapter( * * @param string $server An LDAP server string. * - * @param string $dnformat A distinguised name format string for looking up + * @param string $dnformat A distinguished name format string for looking up * the username. * * @param array $options Use these connection options. @@ -288,8 +287,7 @@ public function newLdapAdapter( $server, $dnformat, array $options = array() - ) - { + ) { return new Adapter\LdapAdapter( new Phpfunc, $server, diff --git a/vendor/aura/auth/src/Exception/FileNotReadable.php b/vendor/aura/auth/src/Exception/FileNotReadable.php index 4dedfeec..5ab223bc 100644 --- a/vendor/aura/auth/src/Exception/FileNotReadable.php +++ b/vendor/aura/auth/src/Exception/FileNotReadable.php @@ -1,23 +1,23 @@ adapter = $adapter; $this->session = $session; } @@ -98,10 +97,9 @@ public function forceLogin( $name, array $data = array(), $status = Status::VALID - ) - { + ) { $started = $this->session->resume() || $this->session->start(); - if (!$started) { + if (! $started) { return false; } diff --git a/vendor/aura/auth/src/Service/LogoutService.php b/vendor/aura/auth/src/Service/LogoutService.php index a6c12b99..f02fb320 100644 --- a/vendor/aura/auth/src/Service/LogoutService.php +++ b/vendor/aura/auth/src/Service/LogoutService.php @@ -54,8 +54,7 @@ class LogoutService public function __construct( AdapterInterface $adapter, SessionInterface $session - ) - { + ) { $this->adapter = $adapter; $this->session = $session; } diff --git a/vendor/aura/auth/src/Service/ResumeService.php b/vendor/aura/auth/src/Service/ResumeService.php index b6845e66..eb08b0b1 100644 --- a/vendor/aura/auth/src/Service/ResumeService.php +++ b/vendor/aura/auth/src/Service/ResumeService.php @@ -79,8 +79,7 @@ public function __construct( SessionInterface $session, Timer $timer, LogoutService $logout_service - ) - { + ) { $this->adapter = $adapter; $this->session = $session; $this->timer = $timer; @@ -100,7 +99,7 @@ public function __construct( public function resume(Auth $auth) { $this->session->resume(); - if (!$this->timedOut($auth)) { + if (! $this->timedOut($auth)) { $auth->setLastActive(time()); $this->adapter->resume($auth); } diff --git a/vendor/aura/auth/src/Session/Segment.php b/vendor/aura/auth/src/Session/Segment.php index 2c7aa0d6..a38be235 100644 --- a/vendor/aura/auth/src/Session/Segment.php +++ b/vendor/aura/auth/src/Session/Segment.php @@ -72,7 +72,7 @@ public function get($key, $alt = null) */ public function set($key, $val) { - if (!isset($_SESSION)) { + if (! isset($_SESSION)) { return; } diff --git a/vendor/aura/auth/src/Session/Timer.php b/vendor/aura/auth/src/Session/Timer.php index 4dae5844..eeacdc3e 100644 --- a/vendor/aura/auth/src/Session/Timer.php +++ b/vendor/aura/auth/src/Session/Timer.php @@ -74,8 +74,7 @@ public function __construct( $ini_cookie_lifetime = 0, $idle_ttl = 1440, $expire_ttl = 14400 - ) - { + ) { $this->ini_gc_maxlifetime = $ini_gc_maxlifetime; $this->ini_cookie_lifetime = $ini_cookie_lifetime; $this->setIdleTtl($idle_ttl); @@ -160,7 +159,7 @@ public function getExpireTtl() public function hasExpired($first_active) { return $this->expire_ttl <= 0 - || ($first_active + $this->getExpireTtl()) < time(); + || ($first_active + $this->getExpireTtl()) < time(); } /** @@ -175,7 +174,7 @@ public function hasExpired($first_active) public function hasIdled($last_active) { return $this->idle_ttl <= 0 - || ($last_active + $this->getIdleTtl()) < time(); + || ($last_active + $this->getIdleTtl()) < time(); } /** diff --git a/vendor/aura/auth/src/Verifier/HtpasswdVerifier.php b/vendor/aura/auth/src/Verifier/HtpasswdVerifier.php index c172fcee..5511e7f3 100644 --- a/vendor/aura/auth/src/Verifier/HtpasswdVerifier.php +++ b/vendor/aura/auth/src/Verifier/HtpasswdVerifier.php @@ -92,7 +92,7 @@ protected function apr1($plaintext, $hashvalue) $binary = $this->computeBinary($plaintext, $salt, $context); $p = $this->computeP($binary); $computed_hash = '$apr1$' . $salt . '$' . $p - . $this->convert64(ord($binary[11]), 3); + . $this->convert64(ord($binary[11]), 3); return $computed_hash === $hashvalue; } diff --git a/vendor/aura/auth/tests/container/bootstrap.php b/vendor/aura/auth/tests/container/bootstrap.php index b8597ebe..480b3ea8 100644 --- a/vendor/aura/auth/tests/container/bootstrap.php +++ b/vendor/aura/auth/tests/container/bootstrap.php @@ -4,7 +4,7 @@ // composer autoloader $composer_autoload = __DIR__ . "/vendor/autoload.php"; -if (!is_readable($composer_autoload)) { +if (! is_readable($composer_autoload)) { echo "Did not find 'vendor/autoload.php'." . PHP_EOL; echo "Try ./phpunit.sh instead of phpunit." . PHP_EOL; exit(1); diff --git a/vendor/aura/auth/tests/unit/src/Adapter/PdoAdapterTest.php b/vendor/aura/auth/tests/unit/src/Adapter/PdoAdapterTest.php index e9a5c51a..6c34c092 100644 --- a/vendor/aura/auth/tests/unit/src/Adapter/PdoAdapterTest.php +++ b/vendor/aura/auth/tests/unit/src/Adapter/PdoAdapterTest.php @@ -43,17 +43,17 @@ protected function buildTable() array( 'username' => 'boshag', 'password' => hash('md5', '123456'), - 'active' => 'y', + 'active' => 'y', ), array( 'username' => 'repeat', 'password' => hash('md5', '234567'), - 'active' => 'y', + 'active' => 'y', ), array( 'username' => 'repeat', 'password' => hash('md5', '234567'), - 'active' => 'n', + 'active' => 'n', ), ); diff --git a/vendor/aura/auth/tests/unit/src/AuthFactoryTest.php b/vendor/aura/auth/tests/unit/src/AuthFactoryTest.php index 128e1c5f..0820bd04 100644 --- a/vendor/aura/auth/tests/unit/src/AuthFactoryTest.php +++ b/vendor/aura/auth/tests/unit/src/AuthFactoryTest.php @@ -2,6 +2,8 @@ namespace Aura\Auth; use PDO; +use Aura\Auth\Session\Session; +use Aura\Auth\Session\Segment; use Aura\Auth\Verifier\FakeVerifier; class AuthFactoryTest extends \PHPUnit_Framework_TestCase @@ -19,6 +21,12 @@ public function testNewAuth() $this->assertInstanceOf('Aura\Auth\Auth', $auth); } + public function testNewAuthWithSessionAndSegment() + { + $auth = $this->factory->newInstance(array(), new Session(array()), new Segment); + $this->assertInstanceOf('Aura\Auth\Auth', $auth); + } + public function testNewPdoAdapter_passwordVerifier() { $pdo = new PDO('sqlite::memory:'); @@ -31,7 +39,7 @@ public function testNewPdoAdapter_passwordVerifier() $this->assertInstanceOf('Aura\Auth\Adapter\PdoAdapter', $adapter); $verifier = $adapter->getVerifier(); - $this->assertInstanceOf('Aura\Auth\Verifier\PasswordVerifier', $verifier); + $this->assertInstanceOf('Aura\Auth\Verifier\PasswordVerifier',$verifier); } public function testNewPdoAdapter_customVerifier() diff --git a/vendor/aura/auth/tests/unit/src/Session/FakeSession.php b/vendor/aura/auth/tests/unit/src/Session/FakeSession.php index d01ead17..4a230dca 100644 --- a/vendor/aura/auth/tests/unit/src/Session/FakeSession.php +++ b/vendor/aura/auth/tests/unit/src/Session/FakeSession.php @@ -25,6 +25,6 @@ public function resume() public function regenerateId() { - $this->session_id++; + $this->session_id ++; } } diff --git a/vendor/aura/auth/tests/unit/src/Verifier/HtpasswdVerifierTest.php b/vendor/aura/auth/tests/unit/src/Verifier/HtpasswdVerifierTest.php index 05784fff..36654cc8 100644 --- a/vendor/aura/auth/tests/unit/src/Verifier/HtpasswdVerifierTest.php +++ b/vendor/aura/auth/tests/unit/src/Verifier/HtpasswdVerifierTest.php @@ -32,7 +32,7 @@ public function testApr() public function testBcrypt() { - if (!function_exists('password_verify')) { + if (! function_exists('password_verify')) { $this->markTestSkipped("password_hash functionality not available. Install ircmaxell/password-compat for 5.3+"); } $hashvalue = '$2y$05$VBdzN9btLNhVZi1tyl8nOeNiQcafX.A8pR/HJT57XHKK2lGmPpaDW'; diff --git a/vendor/aura/auth/tests/unit/src/Verifier/PasswordVerifierTest.php b/vendor/aura/auth/tests/unit/src/Verifier/PasswordVerifierTest.php index b0602c42..52363162 100644 --- a/vendor/aura/auth/tests/unit/src/Verifier/PasswordVerifierTest.php +++ b/vendor/aura/auth/tests/unit/src/Verifier/PasswordVerifierTest.php @@ -5,7 +5,7 @@ class PasswordVerifierTest extends \PHPUnit_Framework_TestCase { public function testBcrypt() { - if (!defined('PASSWORD_BCRYPT')) { + if (! defined('PASSWORD_BCRYPT')) { $this->markTestSkipped("password_hash functionality not available. Install ircmaxell/password-compat for 5.3+"); } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index f97bb24a..515fa378 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -388,35 +388,38 @@ ] }, { - "name": "aura/auth", - "version": "2.0.0-beta2", - "version_normalized": "2.0.0.0-beta2", + "name": "aura/session", + "version": "2.0.1", + "version_normalized": "2.0.1.0", "source": { "type": "git", - "url": "https://github.com/auraphp/Aura.Auth.git", - "reference": "8010400aa090f52e9c4056399c018c4bb96d7fc1" + "url": "https://github.com/auraphp/Aura.Session.git", + "reference": "9e018278794228e40c7695b699c848bea2355a12" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/auraphp/Aura.Auth/zipball/8010400aa090f52e9c4056399c018c4bb96d7fc1", - "reference": "8010400aa090f52e9c4056399c018c4bb96d7fc1", + "url": "https://api.github.com/repos/auraphp/Aura.Session/zipball/9e018278794228e40c7695b699c848bea2355a12", + "reference": "9e018278794228e40c7695b699c848bea2355a12", "shasum": "" }, "require": { "php": ">=5.3.0" }, + "require-dev": { + "aura/di": "~2.0" + }, "suggest": { - "ext/imap": "For IMAP/POP/NNTP integration.", - "ext/ldap": "For LDAP integration.", - "ircmaxell/password-compat": "Provides password_verify() for PHP versions earlier than 5.5" + "ext-mcrypt": "Mcrypt generates the next best secure CSRF tokens.", + "ext-openssl": "OpenSSL generates the best secure CSRF tokens.", + "ircmaxell/random-lib": "A Library For Generating Secure Random Numbers" }, - "time": "2014-11-07 15:41:31", + "time": "2015-03-27 18:33:22", "type": "library", "extra": { "aura": { "type": "library", "config": { - "common": "Aura\\Auth\\_Config\\Common" + "common": "Aura\\Session\\_Config\\Common" } }, "branch-alias": { @@ -426,8 +429,8 @@ "installation-source": "dist", "autoload": { "psr-4": { - "Aura\\Auth\\": "src/", - "Aura\\Auth\\_Config\\": "config/" + "Aura\\Session\\": "src/", + "Aura\\Session\\_Config\\": "config/" } }, "notification-url": "https://packagist.org/downloads/", @@ -436,62 +439,58 @@ ], "authors": [ { - "name": "Aura.Auth Contributors", - "homepage": "https://github.com/auraphp/Aura.Auth/contributors" + "name": "Aura.Session Contributors", + "homepage": "https://github.com/auraphp/Aura.Session/contributors" } ], - "description": "Aura Auth provides a unified interface to authenticate a user with local or remote authentication systems.", - "homepage": "https://github.com/auraphp/Aura.Auth", + "description": "Provides session management functionality, including lazy session starting, session segments, next-request-only (\"flash\") values, and CSRF tools.", + "homepage": "https://github.com/auraphp/Aura.Session", "keywords": [ - "Authentication", - "auth", - "authenticate" + "csrf", + "flash", + "flash message", + "session", + "sessions" ] }, { - "name": "aura/session", - "version": "2.0.1", - "version_normalized": "2.0.1.0", + "name": "aura/auth", + "version": "2.x-dev", + "version_normalized": "2.9999999.9999999.9999999-dev", "source": { "type": "git", - "url": "https://github.com/auraphp/Aura.Session.git", - "reference": "9e018278794228e40c7695b699c848bea2355a12" + "url": "https://github.com/auraphp/Aura.Auth.git", + "reference": "f9691d48860b163641ddf2a1e616d035ff8f885b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/auraphp/Aura.Session/zipball/9e018278794228e40c7695b699c848bea2355a12", - "reference": "9e018278794228e40c7695b699c848bea2355a12", + "url": "https://api.github.com/repos/auraphp/Aura.Auth/zipball/f9691d48860b163641ddf2a1e616d035ff8f885b", + "reference": "f9691d48860b163641ddf2a1e616d035ff8f885b", "shasum": "" }, "require": { "php": ">=5.3.0" }, - "require-dev": { - "aura/di": "~2.0" - }, "suggest": { - "ext-mcrypt": "Mcrypt generates the next best secure CSRF tokens.", - "ext-openssl": "OpenSSL generates the best secure CSRF tokens.", - "ircmaxell/random-lib": "A Library For Generating Secure Random Numbers" + "ext/imap": "For IMAP/POP/NNTP integration.", + "ext/ldap": "For LDAP integration.", + "ircmaxell/password-compat": "Provides password_verify() for PHP versions earlier than 5.5" }, - "time": "2015-03-27 18:33:22", + "time": "2015-08-08 09:48:54", "type": "library", "extra": { "aura": { "type": "library", "config": { - "common": "Aura\\Session\\_Config\\Common" + "common": "Aura\\Auth\\_Config\\Common" } - }, - "branch-alias": { - "dev-develop-2": "2.0.x-dev" } }, - "installation-source": "dist", + "installation-source": "source", "autoload": { "psr-4": { - "Aura\\Session\\": "src/", - "Aura\\Session\\_Config\\": "config/" + "Aura\\Auth\\": "src/", + "Aura\\Auth\\_Config\\": "config/" } }, "notification-url": "https://packagist.org/downloads/", @@ -500,18 +499,16 @@ ], "authors": [ { - "name": "Aura.Session Contributors", - "homepage": "https://github.com/auraphp/Aura.Session/contributors" + "name": "Aura.Auth Contributors", + "homepage": "https://github.com/auraphp/Aura.Auth/contributors" } ], - "description": "Provides session management functionality, including lazy session starting, session segments, next-request-only (\"flash\") values, and CSRF tools.", - "homepage": "https://github.com/auraphp/Aura.Session", + "description": "Aura Auth provides a unified interface to authenticate a user with local or remote authentication systems.", + "homepage": "https://github.com/auraphp/Aura.Auth", "keywords": [ - "csrf", - "flash", - "flash message", - "session", - "sessions" + "Authentication", + "auth", + "authenticate" ] } ]