From a7955ffc5c8b12175ff3ed15f069a936f21fc389 Mon Sep 17 00:00:00 2001 From: multiwebinc Date: Tue, 9 Sep 2014 18:16:29 -0600 Subject: [PATCH 1/6] Allows users to authenticate using an OTP grid card Generates and validates cards similar to this: http://www.entrust.com/wp-content/uploads/2013/08/card_back-patent.jpg Also, due to the bug I found in the random number generator, I am using mt_rand() instead. --- lib/phpSec/Auth/Gridcard.php | 273 +++++++++++++++++++++++++++++++++++ 1 file changed, 273 insertions(+) create mode 100644 lib/phpSec/Auth/Gridcard.php diff --git a/lib/phpSec/Auth/Gridcard.php b/lib/phpSec/Auth/Gridcard.php new file mode 100644 index 0000000..adf4bae --- /dev/null +++ b/lib/phpSec/Auth/Gridcard.php @@ -0,0 +1,273 @@ + + @copyright Copyright (c) Audun Larsen, 2011, 2012 + @link https://github.com/phpsec/phpSec + @license http://opensource.org/licenses/mit-license.php The MIT License + @package phpSec_Experimental + */ + +/** + * Providees pre shared password grid functionality. Experimental. + * @package phpSec_Experimental + */ +class Gridcard { + + public $numCols = 10; + public $numRows = 5; + public $gridChars = '0123456789'; + public $_charset = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + + private $seedRandom; + private $nextCellsRandomSeed; + + /** + * Constructor. + * + * @param \phpSec\Core $psl + * phpSec core Pimple container. + */ + public function __construct(\phpSec\Core $psl) { + $this->psl = $psl; + } + + public function generate($expiry = null) { + $rand = $this->psl['crypt/rand']; + + $this->issued = time(); + + if (isset($expiry)) { + $this->expiry = $expiry; + } + else { + $this->expiry = strtotime("+ 1 year"); + } + + $this->seedRandom = $rand->str(64, $this->_charset); + + // Total number of different combinations is (numCols * numRows)^3 + $this->nextCellsRandomSeed = mt_rand(0, pow($this->numCols * $this->numRows, 3)); + } + + public function save($uid) + { + if (!isset($this->seedRandom) + || !isset($this->expiry) + || !isset($this->nextCellsRandomSeed) + ) { + throw new \phpSec\Exception\GeneralSecurityException('Variables not set correctly'); + } + $store['numCols'] = $this->numCols; + $store['numRows'] = $this->numRows; + $store['seedRandom'] = $this->seedRandom; + $store['chars'] = $this->gridChars; + $store['expiry'] = $this->expiry; + $store['nextCellsSeed'] = $this->nextCellsRandomSeed; + + $storeId = $this->getStoreId($uid); + + $this->psl['store']->write('gridcard', $storeId, $store); + } + + public function validate(Array $values, $uid) + { + $this->getGridValues(); + $cells = $this->getNextCells(); + + for ($i=0; $i < count($cells); $i++) { + preg_match('/\D+/', $cells[$i], $col_matches); + preg_match('/\d+/', $cells[$i], $row_matches); + $col = $col_matches[0]; + $row = $row_matches[0]; + + if (!$this->_validateCell($col, $row, $values[$i])) { + // Get new random seed for next cells + $this->_updateNextCellsRandomSeed($uid); + + return false; + } + } + // Get new random seed for next cells + $this->_updateNextCellsRandomSeed($uid); + return true; + } + + /** + * Validates the value from a specific cell + * @Param mixed $col Integer column number or string column name + * @Param Integer $row row number + * @Param String $val Value to check against. + * @Note This will show false negatives if $val is not a string for cell + * values that start with 0. + */ + private function _validateCell($col, $row, $val) + { + if (!is_numeric($col)) { + $col = $this->_letters_to_num($col); + } + $this->getGridValues(); + + return ((string)$this->_values[$row-1][$col-1] === (string)$val); + } + + public function load($uid) + { + $store = $this->psl['store']; + $storeData = $store->read('gridcard', $this->getStoreId($uid)); + + if($storeData !== false) { + // Delete the entry if it has expired + if ($storeData['expiry'] < time()) { + $store->delete('gridcard', $this->getStoreId($uid)); + return false; + } + + $this->numCols = $storeData['numCols']; + $this->numRows = $storeData['numRows']; + $this->seedRandom = $storeData['seedRandom']; + $this->gridChars = $storeData['chars']; + $this->expiry = $storeData['expiry']; + $this->nextCellsRandomSeed = $storeData['nextCellsSeed']; + + return true; + } + return false; + } + + /** + * Gets the next 3 cells to be used for validation. + * @Note Refreshing the page should *not* get different values. Only after + * validating should they change + */ + public function getNextCells() + { + $next_cells = array(); + // Seed the random number generator + mt_srand($this->nextCellsRandomSeed); + for ($i=0; $i < 3; $i++) { + // Loop to make sure next values are unique + while (!isset($next_cells[$i])) { + $value = $this->_num_to_letters(mt_rand(1, $this->numCols)); + $value .= mt_rand(1, $this->numRows); + if (array_search($value, $next_cells) === false) { + $next_cells[$i] = $value; + } + } + } + return $next_cells; + } + + public function getGridHTML() + { + $this->getGridValues(); + + $html = ' + + + + '; + + for ($c=1; $c<=$this->numCols; $c++) { + $html .= ''; + } + + $html .= ' + + + '; + + for ($r=0; $r<$this->numRows; $r++) { + $html .= ''; + for ($c=0; $c<=$this->numCols; $c++) { + if ($c === 0) { + $html .= ''; + } + else { + $html .= ''; + } + } + $html .= ''; + } + + $html .= ' + +
'.$this->_num_to_letters($c).'
'.($r+1).''.$this->_values[$r][$c-1].'
'; + + return $html; + } + + /** + * Gets all cell values for the grid + * @Return Array + */ + public function getGridValues() + { + $hash = $this->_getStringHash($this->numRows * $this->numCols * 2); + + $rows = str_split($hash, $this->numCols * 2); + + foreach ($rows as $index => $row) { + $cols = str_split($row, 2); + + $this->_values[$index] = $cols; + } + } + + /** + * @Note This needs to be called after every validation (failed or passed) + */ + private function _updateNextCellsRandomSeed($uid) + { + $this->nextCellsRandomSeed = mt_rand(0, pow($this->numCols * $this->numRows, 3)); + $this->save($uid); + } + + private function _getStringHash($length) + { + $string = ''; + + // Seed the random number generator with a number based on the hash so + // that it always returns a specific number + mt_srand(crc32($this->seedRandom)); + + $chars_array = str_split($this->gridChars); + for ($i = 0; $i < $length ; $i++) { + // Note, this is not actually random since we seeded the random + // number generator with a specific value + $string .= $this->gridChars[mt_rand(0,count($chars_array)-1)]; + } + + // Reset the random number generator in case it is used elsewhere + mt_srand(); + + return $string; + } + + private function _num_to_letters($num, $uppercase = true) + { + $letters = ''; + while ($num > 0) { + $code = ($num % 26 == 0) ? 26 : $num % 26; + $letters .= chr($code + 64); + $num = ($num - $code) / 26; + } + return ($uppercase) ? strtoupper(strrev($letters)) : strrev($letters); + } + + private function _letters_to_num($letters) + { + $num = 0; + $arr = array_reverse(str_split($letters)); + + for ($i = 0; $i < count($arr); $i++) { + $num += (ord(strtolower($arr[$i])) - 96) * (pow(26,$i)); + } + return $num; + } + + private function getStoreId($uid) { + return hash('sha512', $uid); + } +} From ca00595546eeeaba17d24d60dfaf1f3b4489c136 Mon Sep 17 00:00:00 2001 From: multiwebinc Date: Tue, 9 Sep 2014 18:17:19 -0600 Subject: [PATCH 2/6] Update Core.php --- lib/phpSec/Core.php | 164 +++++++++++++++++++++++--------------------- 1 file changed, 84 insertions(+), 80 deletions(-) diff --git a/lib/phpSec/Core.php b/lib/phpSec/Core.php index 19f76c6..feadc93 100644 --- a/lib/phpSec/Core.php +++ b/lib/phpSec/Core.php @@ -1,117 +1,121 @@ - - @copyright Copyright (c) Audun Larsen, 2012, 2013 - @link https://github.com/phpsec/phpSec - @license http://opensource.org/licenses/mit-license.php The MIT License - @package phpSec - */ - -/** - * phpSec core class. - * Includes Core phpSec methods, and act as an Pimple DI container. - * - * @author Audun Larsen - * @package phpSec - */ -class Core extends \Pimple { - - /** - * phpSec version consant. - */ - const VERSION = '0.6.3-dev'; - - /** - * Constructor. - * Set up the default objects for phpSec. - */ - public function __construct() { - + + @copyright Copyright (c) Audun Larsen, 2012, 2013 + @link https://github.com/phpsec/phpSec + @license http://opensource.org/licenses/mit-license.php The MIT License + @package phpSec + */ + +/** + * phpSec core class. + * Includes Core phpSec methods, and act as an Pimple DI container. + * + * @author Audun Larsen + * @package phpSec + */ +class Core extends \Pimple { + + /** + * phpSec version consant. + */ + const VERSION = '0.6.3-dev'; + + /** + * Constructor. + * Set up the default objects for phpSec. + */ + public function __construct() { + /* Store object. Must be defined by the developer. */ - $this['store'] = null; - - /* Cache object. Shared object that handles the cache. */ + $this['store'] = null; + + /* Cache object. Shared object that handles the cache. */ $this['cache'] = $this->share(function($psl) { return new Common\Cache($psl); - }); - - /* Session object. Shared object that handles sessions. */ + }); + + /* Session object. Shared object that handles sessions. */ $this['session'] = $this->share(function($psl) { return new Common\Session($psl); - }); - - /** - * Core phpSec objects. - */ + }); + + /** + * Core phpSec objects. + */ $this['auth/authy'] = function() { return new Auth\Authy(); - }; - + }; + $this['auth/mnemonic'] = function($psl) { return new Auth\Mnemonic($psl); - }; - + }; + $this['auth/google'] = function($psl) { return new Auth\Google($psl); - }; - + }; + + $this['auth/gridcard'] = function($psl) { + return new Auth\Gridcard($psl); + }; + $this['auth/otp'] = function($psl) { return new Auth\Otp($psl); - }; - + }; + $this['auth/yubikey'] = function($psl) { return new Auth\Yubikey($psl); - }; - + }; + $this['common/exec'] = function($psl) { return new Common\Exec(); - }; - + }; + $this['common/token'] = function($psl) { return new Common\Token($psl); - }; - + }; + $this['crypt/crypto'] = function($psl) { return new Crypt\Crypto($psl); - }; - + }; + $this['crypt/hash'] = function($psl) { return new Crypt\Hash($psl); - }; - + }; + $this['crypt/rand'] = function($psl) { return new Crypt\Rand(); - }; - + }; + $this['http/hsts'] = function($psl) { return new Http\Hsts(); - }; - + }; + $this['http/url'] = function($psl) { return new Http\Url($psl); - }; - + }; + $this['http/xfo'] = function($psl) { return new Http\Xfo(); - }; - + }; + $this['string/base32'] = function($psl) { return new String\Base32($psl); - }; - + }; + $this['string/compare'] = function($psl) { return new String\Compare(); - }; - + }; + $this['text/filter'] = function($psl) { return new Text\Filter($psl); - }; + }; + + + } - - } - /** * Check structure of an array. * This method checks the structure of an array (only the first layer of it) against @@ -187,8 +191,8 @@ public static function arrayCheck($array, $structure, $strict = true) { * Returns a unique identifier. */ public function genUid() { - $rand = $this['crypt/rand']; - + $rand = $this['crypt/rand']; + $hex = bin2hex($rand->Bytes(32)); $str = substr($hex,0,16) . '-' . substr($hex,16,8) . '-' . substr($hex,24,8) . '-' . substr($hex,32,8) . '-' . substr($hex,40,24); return $str; @@ -211,5 +215,5 @@ public function getUid() { } return $_SESSION['phpSec-uid']; } - -} + +} From e1ee7a94f01c9c6bc0f09d94b82961a0398c9d70 Mon Sep 17 00:00:00 2001 From: multiwebinc Date: Fri, 12 Sep 2014 17:44:28 -0600 Subject: [PATCH 3/6] Adding database capabilities to Authy --- lib/phpSec/Auth/Authy.php | 151 ++++++++++++++++++-------------------- 1 file changed, 73 insertions(+), 78 deletions(-) diff --git a/lib/phpSec/Auth/Authy.php b/lib/phpSec/Auth/Authy.php index 17fb436..a1a84e6 100644 --- a/lib/phpSec/Auth/Authy.php +++ b/lib/phpSec/Auth/Authy.php @@ -3,7 +3,7 @@ phpSec - A PHP security library @author Audun Larsen - @copyright Copyright (c) Audun Larsen, 2012, 2013, 2014 + @copyright Copyright (c) Audun Larsen, 2012 @link https://github.com/phpsec/phpSec @license http://opensource.org/licenses/mit-license.php The MIT License */ @@ -43,6 +43,16 @@ class Authy { 'sandbox' => 'http://sandbox-api.authy.com', ); + /** + * Constructor. + * + * @param \phpSec\Core $psl + * phpSec core Pimple container. + */ + public function __construct(\phpSec\Core $psl) { + $this->psl = $psl; + } + /** * Add a new Authy user and get the Authy ID. * @@ -59,7 +69,7 @@ class Authy { * Returns the users Authy ID on success or false on errors. * @see \phpSec\Auth\Authy::$lastError. */ - public function userNew($email, $cellphone, $countrycode = 1) { + public function userNew($email, $cellphone, $countrycode = 1, $uid) { $data = array( 'user[email]' => $email, @@ -70,8 +80,8 @@ public function userNew($email, $cellphone, $countrycode = 1) { $result = $this->apiCall('new', $data); if($result === false) { - $this->lastError = 'AUTHY_SERVER_ERROR'; - return false; + $this->lastError = 'AUTHY_SERVER_ERROR'; + return false; } if(isset($result->errors)) { @@ -84,7 +94,14 @@ public function userNew($email, $cellphone, $countrycode = 1) { } if(isset($result->user->id)) { - return $result->user->id; + $this->authyId = $result->user->id; + + $store['authyId'] = $this->authyId; + $storeId = $this->getStoreId($uid); + + $this->psl['store']->write('authy', $storeId, $store); + + return $this->authyId; } $this->lastError = 'AUTHY_SERVER_SAYS_NO'; return false; @@ -103,7 +120,11 @@ public function userNew($email, $cellphone, $countrycode = 1) { * Return true if a valid Authy token is supplied, false on any errors. * @see \phpSec\Auth\Authy::$lastError. */ - public function verify($authyId, $token) { + public function verify($authyId = null, $token) { + if (!isset($authyId)) { + $authyId = $this->authyId; + } + $data = array( 'token' => $token, 'authy_id' => $authyId, @@ -113,61 +134,28 @@ public function verify($authyId, $token) { $result = $this->apiCall('verify', $data); if($result === false) { - $this->lastError = 'AUTHY_SERVER_ERROR'; - return false; + $this->lastError = 'AUTHY_SERVER_ERROR'; + return false; } if(isset($result->errors)) { - if(isset($result->errors->message) && $result->errors->message == 'token is invalid') { - $this->lastError = 'AUTHY_SERVER_BAD_OTP'; - } elseif(isset($result->errors->api_key)) { + if(isset($result->errors->token)) { + $this->lastError = 'AUTHY_SERVER_BAD_OTP'; + } elseif(isset($result->errors->api_key)) { $this->lastError = 'AUTHY_SERVER_INVALID_API_KEY'; } else { - $this->lastError = 'AUTHY_SERVER_INVALID_DATA'; - } - return false; + $this->lastError = 'AUTHY_SERVER_INVALID_DATA'; + } + return false; } if(isset($result->token) && $result->token == 'is valid') { - return true; + return true; } return false; } - /** - * Request SMS token. - * - * @param int $authyId - * Authy ID to request SMS token for. - * - * @param bool $force - * Force sending of SMS even for users with App. - * - * @return boolean - * Returns true if SMS request was OK. false if not. - */ - public function requestSms($authyId, $force = false) { - $data = array( - 'authy_id' => $authyId, - 'force' => $force, - ); - - $result = $this->apiCall('sms', $data); - - if ($result === false) { - $this->lastError = 'AUTHY_SERVER_ERROR'; - return false; - } - - if (isset($result->errors)) { - $this->lastError = 'AUTHY_SERVER_INVALID_DATA'; - return false; - } - - return true; - } - /** * Performs a call to the Authy API. * @@ -185,14 +173,14 @@ public function requestSms($authyId, $force = false) { private function apiCall($action, $data) { switch($this->_sandbox) { case true: - $url = $this->_servers['sandbox']; - break; - default: - $url = $this->_servers['production']; + $url = $this->_servers['sandbox']; + break; + default: + $url = $this->_servers['production']; } switch($action) { - case 'new': + case 'new': $url = $url.'/protected/json/users/new?api_key='.$this->_apiKey; $postData = http_build_query($data); $opts = array( @@ -206,27 +194,9 @@ private function apiCall($action, $data) { 'ignore_errors' => true, )); - break; - - case 'verify': - $url = $url.'/protected/json/verify/'.$data['token'].'/'.$data['authy_id'].'?api_key='.$this->_apiKey.'&force=true'; - - $opts = array( - 'http' => array( - 'method' => 'GET', - 'timeout' => $this->_serverTimeout, - 'header' => "User-Agent: phpSec (http://phpseclib.com)", - 'ignore_errors' => true, - )); - - break; - - case 'sms': - $url = $url.'/protected/json/sms/'.$data['authy_id'].'?api_key='.$this->_apiKey; - - if($data['force'] === true) { - $url = $url.'&force=true'; - } + break; + case 'verify': + $url = $url.'/protected/json/verify/'.$data['token'].'/'.$data['authy_id'].'?api_key='.$this->_apiKey; $opts = array( 'http' => array( @@ -236,17 +206,42 @@ private function apiCall($action, $data) { 'ignore_errors' => true, )); - break; - + break; } + $context = stream_context_create($opts); $result = @file_get_contents($url, false, $context); if($result === false) { - return false; + return false; } return json_decode($result); - } + } + + /** + * Loads an authy entry from the database + * + * @param string $uid + * The user ID + * + * @return string + * Authy ID + */ + public function load($uid) + { + $store = $this->psl['store']; + $storeData = $store->read('authy', $this->getStoreId($uid)); + + if($storeData !== false) { + $this->authyId = $storeData['authyId']; + return $this->authyId; + } + return false; + } + + private function getStoreId($uid) { + return hash('sha512', $uid); + } } From 38be32bb22717475624fada24a94f549a7970713 Mon Sep 17 00:00:00 2001 From: multiwebinc Date: Fri, 12 Sep 2014 18:10:30 -0600 Subject: [PATCH 4/6] Adding database capabilities to Authy --- lib/phpSec/Auth/Authy.php | 126 ++++++++++++++++++++++++++++---------- 1 file changed, 95 insertions(+), 31 deletions(-) diff --git a/lib/phpSec/Auth/Authy.php b/lib/phpSec/Auth/Authy.php index a1a84e6..4b84015 100644 --- a/lib/phpSec/Auth/Authy.php +++ b/lib/phpSec/Auth/Authy.php @@ -3,7 +3,7 @@ phpSec - A PHP security library @author Audun Larsen - @copyright Copyright (c) Audun Larsen, 2012 + @copyright Copyright (c) Audun Larsen, 2012, 2013, 2014 @link https://github.com/phpsec/phpSec @license http://opensource.org/licenses/mit-license.php The MIT License */ @@ -35,6 +35,16 @@ class Authy { */ public $lastError = null; + /** + * Authy ID + */ + public $authyId; + + /** + * \phpSec\Core object + */ + private $psl; + /** * Server URLs. */ @@ -65,6 +75,9 @@ public function __construct(\phpSec\Core $psl) { * @param string $countrycode * User countrycode. Defaults to 1 (USA). * + * @param string $uid + * User ID + * * @return mixed * Returns the users Authy ID on success or false on errors. * @see \phpSec\Auth\Authy::$lastError. @@ -80,8 +93,8 @@ public function userNew($email, $cellphone, $countrycode = 1, $uid) { $result = $this->apiCall('new', $data); if($result === false) { - $this->lastError = 'AUTHY_SERVER_ERROR'; - return false; + $this->lastError = 'AUTHY_SERVER_ERROR'; + return false; } if(isset($result->errors)) { @@ -93,15 +106,15 @@ public function userNew($email, $cellphone, $countrycode = 1, $uid) { return false; } - if(isset($result->user->id)) { - $this->authyId = $result->user->id; + if (isset($result->user->id)) { + $this->authyId = $result->user->id; - $store['authyId'] = $this->authyId; - $storeId = $this->getStoreId($uid); + $store['authyId'] = $this->authyId; + $storeId = $this->getStoreId($uid); - $this->psl['store']->write('authy', $storeId, $store); + $this->psl['store']->write('authy', $storeId, $store); - return $this->authyId; + return $this->authyId; } $this->lastError = 'AUTHY_SERVER_SAYS_NO'; return false; @@ -134,28 +147,61 @@ public function verify($authyId = null, $token) { $result = $this->apiCall('verify', $data); if($result === false) { - $this->lastError = 'AUTHY_SERVER_ERROR'; - return false; + $this->lastError = 'AUTHY_SERVER_ERROR'; + return false; } if(isset($result->errors)) { - if(isset($result->errors->token)) { - $this->lastError = 'AUTHY_SERVER_BAD_OTP'; - } elseif(isset($result->errors->api_key)) { + if(isset($result->errors->message) && $result->errors->message == 'token is invalid') { + $this->lastError = 'AUTHY_SERVER_BAD_OTP'; + } elseif(isset($result->errors->api_key)) { $this->lastError = 'AUTHY_SERVER_INVALID_API_KEY'; } else { - $this->lastError = 'AUTHY_SERVER_INVALID_DATA'; - } - return false; + $this->lastError = 'AUTHY_SERVER_INVALID_DATA'; + } + return false; } if(isset($result->token) && $result->token == 'is valid') { - return true; + return true; } return false; } + /** + * Request SMS token. + * + * @param int $authyId + * Authy ID to request SMS token for. + * + * @param bool $force + * Force sending of SMS even for users with App. + * + * @return boolean + * Returns true if SMS request was OK. false if not. + */ + public function requestSms($authyId, $force = false) { + $data = array( + 'authy_id' => $authyId, + 'force' => $force, + ); + + $result = $this->apiCall('sms', $data); + + if ($result === false) { + $this->lastError = 'AUTHY_SERVER_ERROR'; + return false; + } + + if (isset($result->errors)) { + $this->lastError = 'AUTHY_SERVER_INVALID_DATA'; + return false; + } + + return true; + } + /** * Performs a call to the Authy API. * @@ -173,14 +219,14 @@ public function verify($authyId = null, $token) { private function apiCall($action, $data) { switch($this->_sandbox) { case true: - $url = $this->_servers['sandbox']; - break; - default: - $url = $this->_servers['production']; + $url = $this->_servers['sandbox']; + break; + default: + $url = $this->_servers['production']; } switch($action) { - case 'new': + case 'new': $url = $url.'/protected/json/users/new?api_key='.$this->_apiKey; $postData = http_build_query($data); $opts = array( @@ -194,9 +240,10 @@ private function apiCall($action, $data) { 'ignore_errors' => true, )); - break; - case 'verify': - $url = $url.'/protected/json/verify/'.$data['token'].'/'.$data['authy_id'].'?api_key='.$this->_apiKey; + break; + + case 'verify': + $url = $url.'/protected/json/verify/'.$data['token'].'/'.$data['authy_id'].'?api_key='.$this->_apiKey.'&force=true'; $opts = array( 'http' => array( @@ -206,21 +253,38 @@ private function apiCall($action, $data) { 'ignore_errors' => true, )); - break; - } + break; + case 'sms': + $url = $url.'/protected/json/sms/'.$data['authy_id'].'?api_key='.$this->_apiKey; + + if($data['force'] === true) { + $url = $url.'&force=true'; + } + + $opts = array( + 'http' => array( + 'method' => 'GET', + 'timeout' => $this->_serverTimeout, + 'header' => "User-Agent: phpSec (http://phpseclib.com)", + 'ignore_errors' => true, + )); + + break; + + } $context = stream_context_create($opts); $result = @file_get_contents($url, false, $context); if($result === false) { - return false; + return false; } return json_decode($result); - } + } - /** + /** * Loads an authy entry from the database * * @param string $uid From 232d562042fa092bc1d518f85ee7e54c2a5dd15b Mon Sep 17 00:00:00 2001 From: multiwebinc Date: Fri, 12 Sep 2014 18:12:56 -0600 Subject: [PATCH 5/6] Adding database capabilities to Authy --- lib/phpSec/Core.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/phpSec/Core.php b/lib/phpSec/Core.php index feadc93..22bc2b8 100644 --- a/lib/phpSec/Core.php +++ b/lib/phpSec/Core.php @@ -45,8 +45,8 @@ public function __construct() { /** * Core phpSec objects. */ - $this['auth/authy'] = function() { - return new Auth\Authy(); + $this['auth/authy'] = function($psl) { + return new Auth\Authy($psl); }; $this['auth/mnemonic'] = function($psl) { From bb5185a5758b35822b6b4b216a9ee8ee06d548da Mon Sep 17 00:00:00 2001 From: multiwebinc Date: Fri, 23 Jan 2015 00:03:49 -0600 Subject: [PATCH 6/6] Update Core.php --- lib/phpSec/Core.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/phpSec/Core.php b/lib/phpSec/Core.php index 22bc2b8..f35273a 100644 --- a/lib/phpSec/Core.php +++ b/lib/phpSec/Core.php @@ -48,6 +48,12 @@ public function __construct() { $this['auth/authy'] = function($psl) { return new Auth\Authy($psl); }; + + $this['auth/u2f'] = function($psl) { + $scheme = isset($_SERVER['HTTPS']) ? "https://" : "http://"; + $appId = $scheme . $_SERVER['HTTP_HOST']; + return new Auth\U2F($psl, $appId); + }; $this['auth/mnemonic'] = function($psl) { return new Auth\Mnemonic($psl);