cvs: pear /Auth Auth.php package2.xml
| From: | Adam Ashley | Date: | Wed, 26 Sep 2007 03:33:35 +0000 |
| Subject: | cvs: pear /Auth Auth.php package2.xml | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-48683@lists.php.net to get a copy of this message | ||
aashley Wed Sep 26 03:33:35 2007 UTC
Modified files:
/pear/Auth Auth.php package2.xml
Log:
Implemented Request #12087: Ability to select which Advanced Security options are used.
http://cvs.php.net/viewvc.cgi/pear/Auth/Auth.php?r1=1.119&r2=1.120&diff_format=u Index: pear/Auth/Auth.php diff -u pear/Auth/Auth.php:1.119 pear/Auth/Auth.php:1.120 --- pear/Auth/Auth.php:1.119 Mon Jul 2 03:38:52 2007 +++ pear/Auth/Auth.php Wed Sep 26 03:33:35 2007 @@ -18,7 +18,7 @@ * @author Adam Ashley <aashley@php.net> * @copyright 2001-2006 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id: Auth.php,v 1.119 2007/07/02 03:38:52 aashley Exp $ + * @version CVS: $Id: Auth.php,v 1.120 2007/09/26 03:33:35 aashley Exp $ * @link http://pear.php.net/package/Auth */ @@ -56,6 +56,19 @@ */ define('AUTH_LOG_DEBUG', 7); +/** + * Auth Advanced Security - IP Checks + */ +define('AUTH_ADV_IPCHECK', 1); +/** + * Auth Advanced Security - User Agent Checks + */ +define('AUTH_ADV_USERAGENT', 2); +/** + * Auth Advanced Security - Challenge Response + */ +define('AUTH_ADV_CHALLENGE', 3); + /** * PEAR::Auth @@ -69,7 +82,7 @@ * @author Adam Ashley <aashley@php.net> * @copyright 2001-2006 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version Release: @package_version@ File: $Revision: 1.119 $ + * @version Release: @package_version@ File: $Revision: 1.120 $ * @link http://pear.php.net/package/Auth */ class Auth { @@ -218,7 +231,14 @@ * user's IP or useragent have changed across requests. * Turned off by default to preserve BC. * - * @var boolean + * @var mixed Boolean to turn all advanced security options on or off + * Array containing named values turning specific advanced + * security features on or off individually + * array( + * AUTH_ADV_IPCHECK => true, + * AUTH_ADV_USERAGENT => true, + * AUTH_ADV_CHALLENGE => true, + * ); */ var $advancedsecurity = false; @@ -905,11 +925,12 @@ && $this->session['username'] != '') { Auth::updateIdle(); - if ($this->advancedsecurity) { + if ($this->_isAdvancedSecurityEnabled()) { $this->log('Advanced Security Mode Enabled.', AUTH_LOG_DEBUG); // Only Generate the challenge once - if($this->authChecks == 1) { + if ( $this->authChecks == 1 + && $this->_isAdvancedSecurityEnabled(AUTH_ADV_CHALLENGE)) { $this->log('Generating new Challenge Cookie.', AUTH_LOG_DEBUG); $this->session['challengecookieold'] = $this->session['challengecookie']; $this->session['challengecookie'] = md5($this->session['challengekey'].microtime()); @@ -917,7 +938,8 @@ } // Check for ip change - if ( isset($this->server['REMOTE_ADDR']) + if ( $this->_isAdvancedSecurityEnabled(AUTH_ADV_IPCHECK) + && isset($this->server['REMOTE_ADDR']) && $this->session['sessionip'] != $this->server['REMOTE_ADDR']) { $this->log('Security Breach. Remote IP Address changed.', AUTH_LOG_INFO); // Check if the IP of the user has changed, if so we @@ -929,7 +951,8 @@ } // Check for ip change (if connected via proxy) - if ( isset($this->server['HTTP_X_FORWARDED_FOR']) + if ( $this->_isAdvancedSecurityEnabled(AUTH_ADV_IPCHECK) + && isset($this->server['HTTP_X_FORWARDED_FOR']) && $this->session['sessionforwardedfor'] != $this->server['HTTP_X_FORWARDED_FOR']) { $this->log('Security Breach. Forwarded For IP Address changed.', AUTH_LOG_INFO); // Check if the IP of the user connecting via proxy has @@ -942,7 +965,8 @@ } // Check for useragent change - if ( isset($this->server['HTTP_USER_AGENT']) + if ( $this->_isAdvancedSecurityEnabled(AUTH_ADV_USERAGENT) + && isset($this->server['HTTP_USER_AGENT']) && $this->session['sessionuseragent'] != $this->server['HTTP_USER_AGENT']) { $this->log('Security Breach. User Agent changed.', AUTH_LOG_INFO); // Check if the User-Agent of the user has changed, if @@ -957,7 +981,8 @@ // this is the first time and check is skipped // TODO when user open two pages similtaneuly (open in new window,open // in tab) auth breach is caused find out a way around that if possible - if ( isset($this->session['challengecookieold']) + if ( $this->_isAdvancedSecurityEnabled(AUTH_ADV_CHALLENGE) + && isset($this->session['challengecookieold']) && $this->session['challengecookieold'] != $this->cookie['authchallenge']) { $this->log('Security Breach. Challenge Cookie mismatch.', AUTH_LOG_INFO); $this->expired = true; @@ -1286,6 +1311,49 @@ } // }}} + // {{{ _isAdvancedSecurityEnabled() + + /** + * Is advanced security enabled? + * + * Pass one of the Advanced Security constants as the first parameter + * to check if that advanced security check is enabled. + * + * @param integer + * @return boolean + */ + function _isAdvancedSecurityEnabled($feature = null) { + + if (is_null($feature)) { + + if ($this->advancedsecurity === true) + return true; + + if ( is_array($this->advancedsecurity) + && in_array(true, $this->advancedsecurity, true)) + return true; + + return false; + + } else { + + if (is_array($this->advancedsecurity)) { + + if ( isset($this->advancedsecurity[$feature]) + && $this->advancedsecurity[$feature] == true) + return true; + + return false; + + } + + return (bool)$this->advancedsecurity; + + } + + } + + // }}} } ?> http://cvs.php.net/viewvc.cgi/pear/Auth/package2.xml?r1=1.35&r2=1.36&diff_format=u Index: pear/Auth/package2.xml diff -u pear/Auth/package2.xml:1.35 pear/Auth/package2.xml:1.36 --- pear/Auth/package2.xml:1.35 Mon Jul 2 08:25:41 2007 +++ pear/Auth/package2.xml Wed Sep 26 03:33:35 2007 @@ -58,10 +58,10 @@ <email>aharvey@php.net</email> <active>yes</active> </developer> - <date>2007-07-02</date> + <date>2007-09-26</date> <time>10:35:00</time> <version> - <release>1.5.4</release> + <release>1.6.0</release> <api>1.5.0</api> </version> <stability> @@ -70,8 +70,8 @@ </stability> <license uri="http://www.php.net/license">PHP License</license> <notes> - * Fixed Bug #11499: Redundant parameter in Auth_Container_SOAP5::_validateOptions() - definition. Thanks to Koles Mihaly for spotting this. + * Implemented Request #12087: Ability to select which Advanced Security options + are used. </notes> <contents> <dir name="/"> @@ -270,6 +270,23 @@ </dependencies> <phprelease /> <changelog> + <release> + <date>2007-07-02</date> + <time>10:35:00</time> + <version> + <release>1.5.4</release> + <api>1.5.0</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <license uri="http://www.php.net/license">PHP License</license> + <notes> + * Fixed Bug #11499: Redundant parameter in Auth_Container_SOAP5::_validateOptions() + definition. Thanks to Koles Mihaly for spotting this. + </notes> + </release> <release> <date>2007-07-02</date> <time>10:35:00</time>
http://cvs.php.net/viewvc.cgi/pear/Auth/Auth.php?r1=1.119&r2=1.120&diff_format=u Index: pear/Auth/Auth.php diff -u pear/Auth/Auth.php:1.119 pear/Auth/Auth.php:1.120 --- pear/Auth/Auth.php:1.119 Mon Jul 2 03:38:52 2007 +++ pear/Auth/Auth.php Wed Sep 26 03:33:35 2007 @@ -18,7 +18,7 @@ * @author Adam Ashley <aashley@php.net> * @copyright 2001-2006 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id: Auth.php,v 1.119 2007/07/02 03:38:52 aashley Exp $ + * @version CVS: $Id: Auth.php,v 1.120 2007/09/26 03:33:35 aashley Exp $ * @link http://pear.php.net/package/Auth */ @@ -56,6 +56,19 @@ */ define('AUTH_LOG_DEBUG', 7); +/** + * Auth Advanced Security - IP Checks + */ +define('AUTH_ADV_IPCHECK', 1); +/** + * Auth Advanced Security - User Agent Checks + */ +define('AUTH_ADV_USERAGENT', 2); +/** + * Auth Advanced Security - Challenge Response + */ +define('AUTH_ADV_CHALLENGE', 3); + /** * PEAR::Auth @@ -69,7 +82,7 @@ * @author Adam Ashley <aashley@php.net> * @copyright 2001-2006 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version Release: @package_version@ File: $Revision: 1.119 $ + * @version Release: @package_version@ File: $Revision: 1.120 $ * @link http://pear.php.net/package/Auth */ class Auth { @@ -218,7 +231,14 @@ * user's IP or useragent have changed across requests. * Turned off by default to preserve BC. * - * @var boolean + * @var mixed Boolean to turn all advanced security options on or off + * Array containing named values turning specific advanced + * security features on or off individually + * array( + * AUTH_ADV_IPCHECK => true, + * AUTH_ADV_USERAGENT => true, + * AUTH_ADV_CHALLENGE => true, + * ); */ var $advancedsecurity = false; @@ -905,11 +925,12 @@ && $this->session['username'] != '') { Auth::updateIdle(); - if ($this->advancedsecurity) { + if ($this->_isAdvancedSecurityEnabled()) { $this->log('Advanced Security Mode Enabled.', AUTH_LOG_DEBUG); // Only Generate the challenge once - if($this->authChecks == 1) { + if ( $this->authChecks == 1 + && $this->_isAdvancedSecurityEnabled(AUTH_ADV_CHALLENGE)) { $this->log('Generating new Challenge Cookie.', AUTH_LOG_DEBUG); $this->session['challengecookieold'] = $this->session['challengecookie']; $this->session['challengecookie'] = md5($this->session['challengekey'].microtime()); @@ -917,7 +938,8 @@ } // Check for ip change - if ( isset($this->server['REMOTE_ADDR']) + if ( $this->_isAdvancedSecurityEnabled(AUTH_ADV_IPCHECK) + && isset($this->server['REMOTE_ADDR']) && $this->session['sessionip'] != $this->server['REMOTE_ADDR']) { $this->log('Security Breach. Remote IP Address changed.', AUTH_LOG_INFO); // Check if the IP of the user has changed, if so we @@ -929,7 +951,8 @@ } // Check for ip change (if connected via proxy) - if ( isset($this->server['HTTP_X_FORWARDED_FOR']) + if ( $this->_isAdvancedSecurityEnabled(AUTH_ADV_IPCHECK) + && isset($this->server['HTTP_X_FORWARDED_FOR']) && $this->session['sessionforwardedfor'] != $this->server['HTTP_X_FORWARDED_FOR']) { $this->log('Security Breach. Forwarded For IP Address changed.', AUTH_LOG_INFO); // Check if the IP of the user connecting via proxy has @@ -942,7 +965,8 @@ } // Check for useragent change - if ( isset($this->server['HTTP_USER_AGENT']) + if ( $this->_isAdvancedSecurityEnabled(AUTH_ADV_USERAGENT) + && isset($this->server['HTTP_USER_AGENT']) && $this->session['sessionuseragent'] != $this->server['HTTP_USER_AGENT']) { $this->log('Security Breach. User Agent changed.', AUTH_LOG_INFO); // Check if the User-Agent of the user has changed, if @@ -957,7 +981,8 @@ // this is the first time and check is skipped // TODO when user open two pages similtaneuly (open in new window,open // in tab) auth breach is caused find out a way around that if possible - if ( isset($this->session['challengecookieold']) + if ( $this->_isAdvancedSecurityEnabled(AUTH_ADV_CHALLENGE) + && isset($this->session['challengecookieold']) && $this->session['challengecookieold'] != $this->cookie['authchallenge']) { $this->log('Security Breach. Challenge Cookie mismatch.', AUTH_LOG_INFO); $this->expired = true; @@ -1286,6 +1311,49 @@ } // }}} + // {{{ _isAdvancedSecurityEnabled() + + /** + * Is advanced security enabled? + * + * Pass one of the Advanced Security constants as the first parameter + * to check if that advanced security check is enabled. + * + * @param integer + * @return boolean + */ + function _isAdvancedSecurityEnabled($feature = null) { + + if (is_null($feature)) { + + if ($this->advancedsecurity === true) + return true; + + if ( is_array($this->advancedsecurity) + && in_array(true, $this->advancedsecurity, true)) + return true; + + return false; + + } else { + + if (is_array($this->advancedsecurity)) { + + if ( isset($this->advancedsecurity[$feature]) + && $this->advancedsecurity[$feature] == true) + return true; + + return false; + + } + + return (bool)$this->advancedsecurity; + + } + + } + + // }}} } ?> http://cvs.php.net/viewvc.cgi/pear/Auth/package2.xml?r1=1.35&r2=1.36&diff_format=u Index: pear/Auth/package2.xml diff -u pear/Auth/package2.xml:1.35 pear/Auth/package2.xml:1.36 --- pear/Auth/package2.xml:1.35 Mon Jul 2 08:25:41 2007 +++ pear/Auth/package2.xml Wed Sep 26 03:33:35 2007 @@ -58,10 +58,10 @@ <email>aharvey@php.net</email> <active>yes</active> </developer> - <date>2007-07-02</date> + <date>2007-09-26</date> <time>10:35:00</time> <version> - <release>1.5.4</release> + <release>1.6.0</release> <api>1.5.0</api> </version> <stability> @@ -70,8 +70,8 @@ </stability> <license uri="http://www.php.net/license">PHP License</license> <notes> - * Fixed Bug #11499: Redundant parameter in Auth_Container_SOAP5::_validateOptions() - definition. Thanks to Koles Mihaly for spotting this. + * Implemented Request #12087: Ability to select which Advanced Security options + are used. </notes> <contents> <dir name="/"> @@ -270,6 +270,23 @@ </dependencies> <phprelease /> <changelog> + <release> + <date>2007-07-02</date> + <time>10:35:00</time> + <version> + <release>1.5.4</release> + <api>1.5.0</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <license uri="http://www.php.net/license">PHP License</license> + <notes> + * Fixed Bug #11499: Redundant parameter in Auth_Container_SOAP5::_validateOptions() + definition. Thanks to Koles Mihaly for spotting this. + </notes> + </release> <release> <date>2007-07-02</date> <time>10:35:00</time>