cvs: pear /Auth Auth.php Container.php /Auth/Auth Anonymous.php Auth.php Controller.php /Auth/Container DB.php DBLite.php File.php IMAP.php MDB.php
MDB2.php PEAR.php POP3.php RADIUS.php SMBPasswd.php SOAP.php vpopmail.php /Auth/Frontend Html.php /Auth/tests DBContainer.php DBLiteContainer.php
FileContainer.php IMAPContainer.php MDB2Container.php MDBContainer.php POP3Container.php POP3aContainer.php TestAuthContainer.php
auth_container_db_options.php auth_container_file_options.php tests.php

From: Date: Tue, 28 Feb 2006 02:19:23 +0000
Subject: cvs: pear /Auth Auth.php Container.php /Auth/Auth Anonymous.php Auth.php Controller.php /Auth/Container DB.php DBLite.php File.php IMAP.php MDB.php
MDB2.php PEAR.php POP3.php RADIUS.php SMBPasswd.php SOAP.php vpopmail.php /Auth/Frontend Html.php /Auth/tests DBContainer.php DBLiteContainer.php
FileContainer.php IMAPContainer.php MDB2Container.php MDBContainer.php POP3Container.php POP3aContainer.php TestAuthContainer.php
auth_container_db_options.php auth_container_file_options.php tests.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-38716@lists.php.net to get a copy of this message
aashley Tue Feb 28 02:19:23 2006 UTC Modified files: /pear/Auth Auth.php Container.php /pear/Auth/Auth Anonymous.php Auth.php Controller.php /pear/Auth/Container DB.php DBLite.php File.php IMAP.php MDB.php MDB2.php PEAR.php POP3.php RADIUS.php SMBPasswd.php SOAP.php vpopmail.php /pear/Auth/Frontend Html.php /pear/Auth/tests DBContainer.php DBLiteContainer.php FileContainer.php IMAPContainer.php MDB2Container.php MDBContainer.php POP3Container.php POP3aContainer.php TestAuthContainer.php auth_container_db_options.php auth_container_file_options.php tests.php Log: Coding standard clean ups.

http://cvs.php.net/viewcvs.cgi/pear/Auth/Auth.php?r1=1.98&r2=1.99&diff_format=u Index: pear/Auth/Auth.php diff -u pear/Auth/Auth.php:1.98 pear/Auth/Auth.php:1.99 --- pear/Auth/Auth.php:1.98 Tue Feb 21 01:07:19 2006 +++ pear/Auth/Auth.php Tue Feb 28 02:19:22 2006 @@ -16,14 +16,14 @@ // | Authors: Martin Jansen <mj@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Auth.php,v 1.98 2006/02/21 01:07:19 aashley Exp $ +// $Id: Auth.php,v 1.99 2006/02/28 02:19:22 aashley Exp $ // -define('AUTH_IDLED', -1); -define('AUTH_EXPIRED', -2); -define('AUTH_WRONG_LOGIN', -3); -define('AUTH_METHOD_NOT_SUPPORTED', -4); -define('AUTH_SECURITY_BREACH', -5); +define('AUTH_IDLED', -1); +define('AUTH_EXPIRED', -2); +define('AUTH_WRONG_LOGIN', -3); +define('AUTH_METHOD_NOT_SUPPORTED', -4); +define('AUTH_SECURITY_BREACH', -5); /** * PEAR::Auth @@ -32,11 +32,14 @@ * authentication system using PHP. * * @author Martin Jansen <mj@php.net> + * @author Adam Ashley <aashley@php.net> * @package Auth - * @version $Revision: 1.98 $ + * @version $Revision: 1.99 $ */ class Auth { + // {{{ properties + /** * Auth lifetime in seconds * @@ -225,6 +228,10 @@ */ var $authChecks = 0; + // }}} + + // {{{ Auth() [constructor] + /** * Constructor * @@ -249,20 +256,31 @@ if(!session_id()) { // Throw error include_once 'PEAR.php'; - PEAR::throwError('Session could not be started by Auth, possibly headers are already sent, try putting ob_start in the begninig of your script'); + PEAR::throwError('Session could not be started by Auth, ' + .'possibly headers are already sent, try putting ' + .'ob_start in the begninig of your script'); } } // Make Sure Auth session variable is there - if( !isset($_SESSION[$this->_sessionName]) && !isset($GLOBALS['HTTP_SESSION_VARS'][$this->_sessionName]) ) { + if( !isset($_SESSION[$this->_sessionName]) + && !isset($GLOBALS['HTTP_SESSION_VARS'][$this->_sessionName])) { session_register($this->_sessionName); } // Assign Some globals to internal references, this will replace _importGlobalVariable - isset($_SESSION) ? $this->session =& $_SESSION[$this->_sessionName] : $this->session =& $GLOBALS['HTTP_SESSION_VARS'][$this->_sessionName] ; - isset($_SERVER) ? $this->server =& $_SERVER : $this->server =& $GLOBALS['HTTP_SERVER_VARS']; - isset($_POST) ? $this->post =& $_POST : $this->post =& $GLOBALS['HTTP_POST_VARS']; - isset($_COOKIE) ? $this->cookie =& $_COOKIE : $this->cookie =& $GLOBALS['HTTP_COOKIE_VARS']; + isset($_SESSION) + ? $this->session =& $_SESSION[$this->_sessionName] + : $this->session =& $GLOBALS['HTTP_SESSION_VARS'][$this->_sessionName] ; + isset($_SERVER) + ? $this->server =& $_SERVER + : $this->server =& $GLOBALS['HTTP_SERVER_VARS']; + isset($_POST) + ? $this->post =& $_POST + : $this->post =& $GLOBALS['HTTP_POST_VARS']; + isset($_COOKIE) + ? $this->cookie =& $_COOKIE + : $this->cookie =& $GLOBALS['HTTP_COOKIE_VARS']; //isset($_GET) ? $var = &$_GET : $var = &$GLOBALS['HTTP_GET_VARS']; if ($loginFunction != '' && is_callable($loginFunction)) { @@ -286,16 +304,21 @@ } } + // }}} + // {{{ applyAuthOptions() + /** * Set the Auth options * * Some options which are Auth specific will be applied * the rest will be left for usage by the container - * @param array An array of Auth options - * @return array The options which were not applied + * + * @param array An array of Auth options + * @return array The options which were not applied * @access private */ - function &applyAuthOptions(&$options) { + function &applyAuthOptions(&$options) + { if(is_array($options)){ if (!empty($options['sessionName'])) { $this->_sessionName = $options['sessionName']; @@ -320,24 +343,34 @@ } return($options); } + + // }}} + // {{{ _loadStorage() /** * Load Storage Driver if not already loaded * * Suspend storage instantiation to make Auth lighter to use * for calls which do not require login - * @return bool True if the conainer is loaded, false if the container is already loaded + * + * @return bool True if the conainer is loaded, false if the container + * is already loaded * @access private */ - function _loadStorage() { + function _loadStorage() + { if(!is_object($this->storage)) { - $this->storage =& $this->_factory($this->storage_driver, $this->storage_options); + $this->storage =& $this->_factory($this->storage_driver, + $this->storage_options); $this->storage->_auth_obj =& $this; return(true); } return(false); } + // }}} + // {{{ _factory() + /** * Return a storage driver based on $driver and $options * @@ -347,13 +380,17 @@ * @return object Object Storage object * @access private */ - function &_factory($driver, $options = '') { + function &_factory($driver, $options = '') + { $storage_class = 'Auth_Container_' . $driver; - require_once('Auth/Container/' . $driver . '.php'); + include_once 'Auth/Container/' . $driver . '.php'; $obj =& new $storage_class($options); return $obj; } + // }}} + // {{{ assignData() + /** * Assign data from login form to internal values * @@ -367,44 +404,60 @@ * @return void * @access private */ - function assignData() { - if (isset($this->post[$this->_postUsername]) && $this->post[$this->_postUsername] != '') { - $this->username = (get_magic_quotes_gpc() == 1 ? stripslashes($this->post[$this->_postUsername]) : $this->post[$this->_postUsername]); - } - if (isset($this->post[$this->_postPassword]) && $this->post[$this->_postPassword] != '') { - $this->password = (get_magic_quotes_gpc() == 1 ? stripslashes($this->post[$this->_postPassword]) : $this->post[$this->_postPassword] ); + function assignData() + { + if ( isset($this->post[$this->_postUsername]) + && $this->post[$this->_postUsername] != '') { + $this->username = (get_magic_quotes_gpc() == 1 + ? stripslashes($this->post[$this->_postUsername]) + : $this->post[$this->_postUsername]); + } + if ( isset($this->post[$this->_postPassword]) + && $this->post[$this->_postPassword] != '') { + $this->password = (get_magic_quotes_gpc() == 1 + ? stripslashes($this->post[$this->_postPassword]) + : $this->post[$this->_postPassword] ); } } + // }}} + // {{{ start() + /** * Start new auth session * * @return void * @access public */ - function start() { + function start() + { $this->assignData(); if (!$this->checkAuth() && $this->allowLogin) { $this->login(); } } + // }}} + // {{{ login() + /** * Login function * * @return void * @access private */ - function login() { + function login() + { $login_ok = false; $this->_loadStorage(); + // Check if using challenge response - (isset($this->post['authsecret']) && $this->post['authsecret'] == 1) ? $usingChap = true : $usingChap = false; + (isset($this->post['authsecret']) && $this->post['authsecret'] == 1) + ? $usingChap = true + : $usingChap = false; - /** - * When the user has already entered a username, - * we have to validate it. - */ + + // When the user has already entered a username, we have to validate it. if (!empty($this->username)) { if (true === $this->storage->fetchData($this->username, $this->password, $usingChap)) { $this->session['challengekey'] = md5($this->username.$this->password); @@ -416,29 +469,21 @@ $this->setAuth($this->username); if (is_callable($this->loginCallback)) { call_user_func_array($this->loginCallback, array($this->username, $this)); - #$method = $this->loginCallback; - #$this->$method($this->username, $this); } } - /** - * If the login failed or the user entered no username, - * output the login screen again. - */ + // If the login failed or the user entered no username, + // output the login screen again. if (!empty($this->username) && !$login_ok) { $this->status = AUTH_WRONG_LOGIN; if (is_callable($this->loginFailedCallback)) { call_user_func_array($this->loginFailedCallback, array($this->username, $this)); - #$method = $this->loginFailedCallback; - #$this->$method($this->username, $this->status, $this); } } if ((empty($this->username) || !$login_ok) && $this->showLogin) { if (is_callable($this->loginFunction)) { call_user_func_array($this->loginFunction, array($this->username, $this->status, $this)); - #$method = $this->loginFunction; - #$this->$method($this->username, $this->status, $this); } else { // BC fix Auth used to use drawLogin for this // call is sub classes implement this @@ -447,7 +492,7 @@ } // New Login form - include_once('Auth/Frontend/Html.php'); + include_once 'Auth/Frontend/Html.php'; return Auth_Frontend_Html::render($this, $this->username); } } else { @@ -455,6 +500,9 @@ } } + // }}} + // {{{ setExpire() + /** * Set the maximum expire time * @@ -463,10 +511,14 @@ * @return void * @access public */ - function setExpire($time, $add = false) { + function setExpire($time, $add = false) + { $add ? $this->expire += $time : $this->expire = $time; } + // }}} + // {{{ setIdle() + /** * Set the maximum idle time * @@ -475,10 +527,14 @@ * @return void * @access public */ - function setIdle($time, $add = false) { + function setIdle($time, $add = false) + { $add ? $this->idle += $time : $this->idle = $time; } + // }}} + // {{{ setSessionName() + /** * Set name of the session to a customized value. * @@ -492,11 +548,17 @@ * @return void * @access public */ - function setSessionName($name = 'session') { + function setSessionName($name = 'session') + { $this->_sessionName = '_auth_'.$name; - isset($_SESSION) ? $this->session =& $_SESSION[$this->_sessionName] : $this->session =& $GLOBALS['HTTP_SESSION_VARS'][$this->_sessionName] ; + isset($_SESSION) + ? $this->session =& $_SESSION[$this->_sessionName] + : $this->session =& $GLOBALS['HTTP_SESSION_VARS'][$this->_sessionName] ; } + // }}} + // {{{ setShowLogin() + /** * Should the login form be displayed if neccessary? * @@ -504,10 +566,14 @@ * @return void * @access public */ - function setShowLogin($showLogin = true) { + function setShowLogin($showLogin = true) + { $this->showLogin = $showLogin; } + // }}} + // {{{ setAllowLogin() + /** * Should the login form be displayed if neccessary? * @@ -515,9 +581,13 @@ * @return void * @access public */ - function setAllowLogin($allowLogin = true) { + function setAllowLogin($allowLogin = true) + { $this->allowLogin = $allowLogin; } + + // }}} + // {{{ setLoginCallback() /** * Register a callback function to be called on user login. @@ -528,10 +598,14 @@ * @see setLogoutCallback() * @access public */ - function setLoginCallback($loginCallback) { + function setLoginCallback($loginCallback) + { $this->loginCallback = $loginCallback; } + // }}} + // {{{ setFailedLoginCallback() + /** * Register a callback function to be called on failed user login. * The function will receive a single parameter, the username and a reference to the auth object. @@ -540,10 +614,14 @@ * @return void * @access public */ - function setFailedLoginCallback($loginFailedCallback) { + function setFailedLoginCallback($loginFailedCallback) + { $this->loginFailedCallback = $loginFailedCallback; } + // }}} + // {{{ setLogoutCallback() + /** * Register a callback function to be called on user logout. * The function will receive three parameters, the username and a reference to the auth object. @@ -553,10 +631,14 @@ * @see setLoginCallback() * @access public */ - function setLogoutCallback($logoutCallback) { + function setLogoutCallback($logoutCallback) + { $this->logoutCallback = $logoutCallback; } + // }}} + // {{{ setAuthData() + /** * Register additional information that is to be stored * in the session. @@ -568,13 +650,17 @@ * @return void * @access public */ - function setAuthData($name, $value, $overwrite = true) { + function setAuthData($name, $value, $overwrite = true) + { if (!empty($this->session['data'][$name]) && $overwrite == false) { return; } $this->session['data'][$name] = $value; } + // }}} + // {{{ getAuthData() + /** * Get additional information that is stored in the session. * @@ -585,7 +671,8 @@ * @return mixed Value of the data field. * @access public */ - function getAuthData($name = null) { + function getAuthData($name = null) + { if (!isset($this->session['data'])) { return null; } @@ -598,6 +685,9 @@ return null; } + // }}} + // {{{ setAuth() + /** * Register variable in a session telling that the user * has logged in successfully @@ -606,7 +696,8 @@ * @return void * @access public */ - function setAuth($username) { + function setAuth($username) + { // #2021 - Change the session id to avoid session fixation attacks php 4.3.3 > session_regenerate_id(); @@ -619,8 +710,12 @@ $this->session['data'] = array(); } - $this->session['sessionip'] = isset($this->server['REMOTE_ADDR']) ? $this->server['REMOTE_ADDR'] : ''; - $this->session['sessionuseragent'] = isset($this->server['HTTP_USER_AGENT']) ? $this->server['HTTP_USER_AGENT'] : ''; + $this->session['sessionip'] = isset($this->server['REMOTE_ADDR']) + ? $this->server['REMOTE_ADDR'] + : ''; + $this->session['sessionuseragent'] = isset($this->server['HTTP_USER_AGENT']) + ? $this->server['HTTP_USER_AGENT'] + : ''; // This should be set by the container to something more safe // Like md5(passwd.microtime) @@ -636,6 +731,9 @@ $this->session['timestamp'] = time(); $this->session['idle'] = time(); } + + // }}} + // {{{ setAdvancedSecurity() /** * Enables advanced security checks @@ -643,29 +741,34 @@ * Currently only ip change and useragent change * are detected * @todo Add challenge cookies - Create a cookie which changes every time - * and contains some challenge key which the server can verify with a session var - * cookie might need to be crypted (user pass) + * and contains some challenge key which the server can verify with + * a session var cookie might need to be crypted (user pass) * @param bool Enable or disable * @return void * @access public */ - function setAdvancedSecurity($flag=true) { + function setAdvancedSecurity($flag=true) + { $this->advancedsecurity = $flag; } + // }}} + // {{{ checkAuth() + /** * Checks if there is a session with valid auth information. * * @access public * @return boolean Whether or not the user is authenticated. */ - function checkAuth() { + function checkAuth() + { $this->authChecks++; if (isset($this->session)) { // Check if authentication session is expired - if ($this->expire > 0 && - isset($this->session['timestamp']) && - ($this->session['timestamp'] + $this->expire) < time()) { + if ( $this->expire > 0 + && isset($this->session['timestamp']) + && ($this->session['timestamp'] + $this->expire) < time()) { $this->expired = true; $this->status = AUTH_EXPIRED; $this->logout(); @@ -673,49 +776,58 @@ } // Check if maximum idle time is reached - if ($this->idle > 0 && - isset($this->session['idle']) && - ($this->session['idle'] + $this->idle) < time()) { + if ( $this->idle > 0 + && isset($this->session['idle']) + && ($this->session['idle'] + $this->idle) < time()) { $this->idled = true; $this->status = AUTH_IDLED; $this->logout(); return false; } - if (isset($this->session['registered']) && - isset($this->session['username']) && - $this->session['registered'] == true && - $this->session['username'] != '') { + if ( isset($this->session['registered']) + && isset($this->session['username']) + && $this->session['registered'] == true + && $this->session['username'] != '') { Auth::updateIdle(); if ($this->advancedsecurity) { + // Only Generate the challenge once if($this->authChecks == 1) { $this->session['challengecookieold'] = $this->session['challengecookie']; $this->session['challengecookie'] = md5($this->session['challengekey'].microtime()); setcookie('authchallenge', $this->session['challengecookie']); } + // Check for ip change - if ( isset($this->server['REMOTE_ADDR']) && $this->session['sessionip'] != $this->server['REMOTE_ADDR']) { - // Check if the IP of the user has changed, if so we assume a man in the middle attack and log him out + if ( isset($this->server['REMOTE_ADDR']) + && $this->session['sessionip'] != $this->server['REMOTE_ADDR']) { + // Check if the IP of the user has changed, if so we + // assume a man in the middle attack and log him out $this->expired = true; $this->status = AUTH_SECURITY_BREACH; $this->logout(); return false; } + // Check for useragent change - if ( isset($this->server['HTTP_USER_AGENT']) && $this->session['sessionuseragent'] != $this->server['HTTP_USER_AGENT']) { - // Check if the User-Agent of the user has changed, if so we assume a man in the middle attack and log him out + if ( isset($this->server['HTTP_USER_AGENT']) + && $this->session['sessionuseragent'] != $this->server['HTTP_USER_AGENT']) { + // Check if the User-Agent of the user has changed, if + // so we assume a man in the middle attack and log him out $this->expired = true; $this->status = AUTH_SECURITY_BREACH; $this->logout(); return false; } - // Check challenge cookie here, if challengecookieold is not set 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']) && $this->session['challengecookieold'] != $this->cookie['authchallenge']) { + // Check challenge cookie here, if challengecookieold is not set + // 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']) + && $this->session['challengecookieold'] != $this->cookie['authchallenge']) { $this->expired = true; $this->status = AUTH_SECURITY_BREACH; $this->logout(); @@ -730,31 +842,43 @@ return false; } + // }}} + // {{{ staticCheckAuth() [static] + /** * Statically checks if there is a session with valid auth information. * * @access public * @see checkAuth * @return boolean Whether or not the user is authenticated. + * @static */ - function staticCheckAuth($options = null) { + function staticCheckAuth($options = null) + { static $staticAuth; if(!isset($staticAuth)) { $staticAuth = new Auth('null', $options); } - return( $staticAuth->checkAuth() ); + return $staticAuth->checkAuth(); } + // }}} + // {{{ getAuth() + /** * Has the user been authenticated? * * @access public * @return bool True if the user is logged in, otherwise false. */ - function getAuth() { + function getAuth() + { return $this->checkAuth(); } + // }}} + // {{{ logout() + /** * Logout function * @@ -765,11 +889,10 @@ * @access public * @return void */ - function logout() { + function logout() + { if (is_callable($this->logoutCallback)) { call_user_func_array($this->logoutCallback, array($this->session['username'], $this)); - #$method = $this->logoutCallback; - #$this->$method($this->session['username'], $this); } $this->username = ''; @@ -778,6 +901,9 @@ $this->session = null; } + // }}} + // {{{ updateIdle() + /** * Update the idletime * @@ -789,6 +915,9 @@ $this->session['idle'] = time(); } + // }}} + // {{{ getUsername() + /** * Get the username * @@ -803,6 +932,9 @@ return(''); } + // }}} + // {{{ getStatus() + /** * Get the current status * @@ -813,6 +945,9 @@ { return $this->status; } + + // }}} + // {{{ getPostUsernameField() /** * Gets the post varible used for the username @@ -820,20 +955,28 @@ * @return string * @access public */ - function getPostUsernameField() { + function getPostUsernameField() + { return($this->_postUsername); } + // }}} + // {{{ getPostPasswordField() + /** * Gets the post varible used for the username * * @return string * @access public */ - function getPostPasswordField() { + function getPostPasswordField() + { return($this->_postPassword); } + // }}} + // {{{ sessionValidThru() + /** * Returns the time up to the session is valid * @@ -848,6 +991,9 @@ return ($this->session['idle'] + $this->idle); } + // }}} + // {{{ listUsers() + /** * List all users that are currently available in the storage * container @@ -861,6 +1007,9 @@ return $this->storage->listUsers(); } + // }}} + // {{{ addUser() + /** * Add user to the storage container * @@ -877,6 +1026,9 @@ return $this->storage->addUser($username, $password, $additional); } + // }}} + // {{{ removeUser() + /** * Remove user from the storage container * @@ -891,6 +1043,9 @@ return $this->storage->removeUser($username); } + // }}} + // {{{ changePassword() + /** * Change password for user in the storage container * @@ -905,5 +1060,8 @@ $this->_loadStorage(); return $this->storage->changePassword($username, $password); } + + // }}} + } ?> http://cvs.php.net/viewcvs.cgi/pear/Auth/Container.php?r1=1.20&r2=1.21&diff_format=u Index: pear/Auth/Container.php diff -u pear/Auth/Container.php:1.20 pear/Auth/Container.php:1.21 --- pear/Auth/Container.php:1.20 Sun Jan 8 12:42:37 2006 +++ pear/Auth/Container.php Tue Feb 28 02:19:22 2006 @@ -1,5 +1,5 @@ <?php -// +/* vim: set expandtab tabstop=4 shiftwidth=4: */ // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ @@ -16,18 +16,21 @@ // | Authors: Martin Jansen <mj@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Container.php,v 1.20 2006/01/08 12:42:37 lsmith Exp $ +// $Id: Container.php,v 1.21 2006/02/28 02:19:22 aashley Exp $ // /** * Storage class for fetching login data * * @author Martin Jansen <mj@php.net> + * @author Adam Ashley <aashley@php.net> * @package Auth */ class Auth_Container { + // {{{ properties + /** * User that is currently selected from the storage container. * @@ -35,6 +38,10 @@ */ var $activeUser = ""; + // }}} + + // {{{ Auth_Container() [constructor] + /** * Constructor * @@ -42,9 +49,13 @@ * * @access public */ - function Auth_Container() { + function Auth_Container() + { } + // }}} + // {{{ fetchData() + /** * Fetch data from storage container * @@ -52,7 +63,8 @@ * * @access public */ - function fetchData($username, $password, $isChallengeResponse=false) { + function fetchData($username, $password, $isChallengeResponse=false) + { } // }}} @@ -93,31 +105,46 @@ break; } } + + // }}} + // {{{ supportsChallengeResponse() /** * Returns true if the container supports Challenge Response * password authentication */ - function supportsChallengeResponse() { + function supportsChallengeResponse() + { return(false); } + + // }}} + // {{{ getCryptType() /** * Returns the crypt current crypt type of the container * * @return string */ - function getCryptType() { + function getCryptType() + { return(''); } + // }}} + // {{{ listUsers() + /** * List all users that are available from the storage container */ - function listUsers() { + function listUsers() + { return AUTH_METHOD_NOT_SUPPORTED; } + // }}} + // {{{ getUser() + /** * Returns a user assoc array * @@ -125,7 +152,8 @@ * * @param string The username */ - function getUser($username) { + function getUser($username) + { $users = $this->listUsers(); if ($users === AUTH_METHOD_NOT_SUPPORTED) { return AUTH_METHOD_NOT_SUPPORTED; @@ -138,6 +166,9 @@ return false; } + // }}} + // {{{ addUser() + /** * Add a new user to the storage container * @@ -147,28 +178,40 @@ * * @return boolean */ - function addUser($username, $password, $additional=null) { + function addUser($username, $password, $additional=null) + { return AUTH_METHOD_NOT_SUPPORTED; } + // }}} + // {{{ removeUser() + /** * Remove user from the storage container * * @param string Username */ - function removeUser($username) { + function removeUser($username) + { return AUTH_METHOD_NOT_SUPPORTED; } + // }}} + // {{{ changePassword() + /** * Change password for user in the storage container * * @param string Username * @param string The new password */ - function changePassword($username, $password) { + function changePassword($username, $password) + { return AUTH_METHOD_NOT_SUPPORTED; } + // }}} + } + ?> http://cvs.php.net/viewcvs.cgi/pear/Auth/Auth/Anonymous.php?r1=1.2&r2=1.3&diff_format=u Index: pear/Auth/Auth/Anonymous.php diff -u pear/Auth/Auth/Anonymous.php:1.2 pear/Auth/Auth/Anonymous.php:1.3 --- pear/Auth/Auth/Anonymous.php:1.2 Sun Jan 8 12:36:48 2006 +++ pear/Auth/Auth/Anonymous.php Tue Feb 28 02:19:22 2006 @@ -1,51 +1,127 @@ <?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2003 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 2.02 of the PHP license, | +// | that is bundled with this package in the file LICENSE, and is | +// | available at through the world-wide-web at | +// | http://www.php.net/license/2_02.txt. | +// | If you did not receive a copy of the PHP license and are unable to | +// | obtain it through the world-wide-web, please send a note to | +// | license@php.net so we can mail you a copy immediately. | +// +----------------------------------------------------------------------+ +// | Authors: Martin Jansen <mj@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: Anonymous.php,v 1.3 2006/02/28 02:19:22 aashley Exp $ +// - -include_once 'Auth.php'; +require_once 'Auth.php'; /** + * Anonymouse Authentication + * * This class provides anonymous authentication * if username and password were not supplied * + * @author Yavor Shahpasov <yavo@netsmart.com.cy> + * @author Adam Ashley <aashley@php.net> + * @package Auth + * @version $Revision: 1.3 $ */ -class Auth_Anonymous extends Auth { +class Auth_Anonymous extends Auth +{ + + // {{{ properties + /** + * Whether to allow anonymous authentication + * + * @var boolean + */ var $allow_anonymous = true; + + /** + * Username to use for anonymous user + * + * @var string + */ var $anonymous_username = 'anonymous'; + + // }}} + + // {{{ Auth_Anonymous() [constructor] /** - * Pass all parameters to Parent Auth class - */ + * Pass all parameters to Parent Auth class + * + * Set up the storage driver. + * + * @param string Type of the storage driver + * @param mixed Additional options for the storage driver + * (example: if you are using DB as the storage + * driver, you have to pass the dsn string here) + * + * @param string Name of the function that creates the login form + * @param boolean Should the login form be displayed if neccessary? + * @return void + * @see Auth::Auth() + */ function Auth_Anonymous($storageDriver, $options = '', $loginFunction = '', $showLogin = true) { parent::Auth($storageDriver, $options, $loginFunction, $showLogin); } + + // }}} + // {{{ login() /** - * If no username & password is passed - * then login the user as anonymous - */ + * Login function + * + * If no username & password is passed then login as the username + * provided in $this->anonymous_username else call standard login() + * function. + * + * @return void + * @access private + * @see Auth::login() + */ function login() { - if ( $this->allow_anonymous && empty($this->username) && empty($this->password) ) { + if ( $this->allow_anonymous + && empty($this->username) + && empty($this->password) ) { $this->setAuth($this->anonymous_username); if (is_callable($this->loginCallback)) { - call_user_func_array($this->loginCallback, array($this->username, &$this) ); + call_user_func_array($this->loginCallback, array($this->username, $this) ); } } else { - print "Real Login"; + // Call normal login system parent::login(); } } + + // }}} + // {{{ forceLogin() /** - * Force the user to login - * - */ + * Force the user to login + * + * Calling this function forces the user to provide a real username and + * password before continuing. + * + * @return void + */ function forceLogin() { $this->allow_anonymous = false; if( !empty($this->session['username']) && $this->session['username'] == $this->anonymous_username ) { $this->logout(); } } + + // }}} + } ?> http://cvs.php.net/viewcvs.cgi/pear/Auth/Auth/Auth.php?r1=1.1&r2=1.2&diff_format=u Index: pear/Auth/Auth/Auth.php diff -u pear/Auth/Auth/Auth.php:1.1 pear/Auth/Auth/Auth.php:1.2 --- pear/Auth/Auth/Auth.php:1.1 Mon Sep 8 11:25:36 2003 +++ pear/Auth/Auth/Auth.php Tue Feb 28 02:19:22 2006 @@ -1,5 +1,29 @@ <?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2003 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 2.02 of the PHP license, | +// | that is bundled with this package in the file LICENSE, and is | +// | available at through the world-wide-web at | +// | http://www.php.net/license/2_02.txt. | +// | If you did not receive a copy of the PHP license and are unable to | +// | obtain it through the world-wide-web, please send a note to | +// | license@php.net so we can mail you a copy immediately. | +// +----------------------------------------------------------------------+ +// | Authors: Martin Jansen <mj@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: Auth.php,v 1.2 2006/02/28 02:19:22 aashley Exp $ +// -include_once('Auth.php'); +/** + * Compatibility File + * + * Provide compatibility with previous Auth include location. + */ +require_once 'Auth.php'; -?> \ No newline at end of file +?> http://cvs.php.net/viewcvs.cgi/pear/Auth/Auth/Controller.php?r1=1.7&r2=1.8&diff_format=u Index: pear/Auth/Auth/Controller.php diff -u pear/Auth/Auth/Controller.php:1.7 pear/Auth/Auth/Controller.php:1.8 --- pear/Auth/Auth/Controller.php:1.7 Sun Jul 4 21:21:04 2004 +++ pear/Auth/Auth/Controller.php Tue Feb 28 02:19:22 2006 @@ -1,61 +1,109 @@ <?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2003 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 2.02 of the PHP license, | +// | that is bundled with this package in the file LICENSE, and is | +// | available at through the world-wide-web at | +// | http://www.php.net/license/2_02.txt. | +// | If you did not receive a copy of the PHP license and are unable to | +// | obtain it through the world-wide-web, please send a note to | +// | license@php.net so we can mail you a copy immediately. | +// +----------------------------------------------------------------------+ +// | Authors: Martin Jansen <mj@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: Controller.php,v 1.8 2006/02/28 02:19:22 aashley Exp $ +// /** - * Controlls access to a group of php access - * and redirects to a predefined login page as - * needed - * - * In all pages - * <code> - * include_once('Auth.php'); - * include_once('Auth/Controller.php'); - * $_auth = new Auth('File', 'passwd'); - * $authController = new Auth_Controller($_auth, 'login.php', 'index.php'); - * $authController->start(); - * </code> - * - * In login.php - * <code> - * include_once('Auth.php'); - * include_once('Auth/Controller.php'); - * $_auth = new Auth('File', 'passwd'); - * $authController = new Auth_Controller($_auth, 'login.php', 'index.php'); - * $authController->start(); - * if( $authController->isAuthorised() ){ - * $authController->redirectBack(); - * } - * </code> - * - */ -class Auth_Controller { + * Controlls access to a group of php access + * and redirects to a predefined login page as + * needed + * + * In all pages + * <code> + * include_once('Auth.php'); + * include_once('Auth/Controller.php'); + * $_auth = new Auth('File', 'passwd'); + * $authController = new Auth_Controller($_auth, 'login.php', 'index.php'); + * $authController->start(); + * </code> + * + * In login.php + * <code> + * include_once('Auth.php'); + * include_once('Auth/Controller.php'); + * $_auth = new Auth('File', 'passwd'); + * $authController = new Auth_Controller($_auth, 'login.php', 'index.php'); + * $authController->start(); + * if( $authController->isAuthorised() ){ + * $authController->redirectBack(); + * } + * </code> + * + * @author Yavor Shahpasov <yavo@netsmart.com.cy> + * @author Adam Ashley <aashley@php.net> + * @package Auth + * @version $Revision: 1.8 $ + */ +class Auth_Controller +{ - /** var Auth An auth instance */ + // {{{ properties + + /** + * The Auth instance this controller is managing + * + * @var object Auth + */ var $auth = null; - /** var string The login url */ + + /** + * The login URL + * @var string + * */ var $login = null; - /** var string The default index page, used when login redirects and the caller page in not set or is the login page it's self */ + + /** + * The default index page to use when the caller page is not set + * + * @var string + */ var $default = null; - /** var bool If this is set to true auther a succesfull login the Auth_Controller::redirectBack() is invoked automatically */ + + /** + * If this is set to true after a succesfull login the + * Auth_Controller::redirectBack() is invoked automatically + * + * @var boolean + */ var $autoRedirectBack = false; + + // }}} + + // {{{ Auth_Controller() [constructor] /** - * Constructor - * - * @param Auth An auth instance - * @param string The login page - * @param string The default page to go to if return page is not set - * @param array Some rules about which urls need to be sent to the login page - * - * @todo Add a list of urls which need redirection - */ - function Auth_Controller(&$auth_obj, $login='login.php', $default='index.php', $accessList=array()) { - #print $auth_obj; + * Constructor + * + * @param Auth An auth instance + * @param string The login page + * @param string The default page to go to if return page is not set + * @param array Some rules about which urls need to be sent to the login page + * @return void + * @todo Add a list of urls which need redirection + */ + function Auth_Controller(&$auth_obj, $login='login.php', $default='index.php', $accessList=array()) + { $this->auth =& $auth_obj; $this->_loginPage = $login; $this->_defaultPage = $default; @session_start(); if (!empty($_GET['return']) && $_GET['return'] && !strstr($_GET['return'], $this->_loginPage)) { - #print "Return: {$_GET['return']} <br/>"; $this->auth->setAuthData('returnUrl', $_GET['return']); } @@ -63,22 +111,32 @@ $this->auth->status = $_GET['authstatus']; } } + + // }}} + // {{{ setAutoRedirectBack() /** - * Enables auto redirection when login is done - * - * @param bool Sets the autoRedirectBack flag to this - * @see Auth_Controller::autoRedirectBack - * - */ - function setAutoRedirectBack($flag = true){ + * Enables auto redirection when login is done + * + * @param bool Sets the autoRedirectBack flag to this + * @see Auth_Controller::autoRedirectBack + * @return void + */ + function setAutoRedirectBack($flag = true) + { $this->autoRedirectBack = $flag; } + + // }}} + // {{{ redirectBack() /** - * Redirects Back to the calling page - */ - function redirectBack() { + * Redirects Back to the calling page + * + * @return void + */ + function redirectBack() + { // If redirectback go there // else go to the default page @@ -101,14 +159,19 @@ header('Location:'.$returnUrl); print("You could not be redirected to <a href=\"$returnUrl\">$returnUrl</a>"); } + + // }}} + // {{{ redirectLogin() /** - * Redirects to the login Page - * if not authorised + * Redirects to the login Page if not authorised * * put return page on the query or in auth + * + * @return void */ - function redirectLogin() { + function redirectLogin() + { // Go to the login Page // For Auth, put some check to avoid infinite redirects, this should at least exclude @@ -119,17 +182,21 @@ $url .= '?'; } - #print "ServerPhp:".$_SERVER['PHP_SELF']; if(!strstr($_SERVER['PHP_SELF'], $this->_loginPage)) { $url .= 'return='.urlencode($_SERVER['PHP_SELF']); } + // Track the auth status if($this->auth->status != '') { $url .= '&authstatus='.$this->auth->status; } + header('Location:'.$url); print("You could not be redirected to <a href=\"$url\">$url</a>"); } + + // }}} + // {{{ start() /** * Starts the Auth Procedure @@ -137,9 +204,11 @@ * If the page requires login the user is redirected to the login page * otherwise the Auth::start is called to initialize Auth * + * @return void * @todo Implement an access list which specifies which urls/pages need login and which do not */ - function start() { + function start() + { // Check the accessList here // ACL should be a list of urls with allow/deny // If allow set allowLogin to false @@ -158,47 +227,68 @@ } + + // }}} + // {{{ isAuthorised() /** * Checks is the user is logged on * @see Auth::checkAuth() */ - function isAuthorised() { + function isAuthorised() + { return($this->auth->checkAuth()); } + // }}} + // {{{ checkAuth() + /** * Proxy call to auth * @see Auth::checkAuth() */ - function checkAuth() { + function checkAuth() + { return($this->auth->checkAuth()); } + // }}} + // {{{ logout() + /** * Proxy call to auth * @see Auth::logout() */ - function logout() { + function logout() + { return($this->auth->logout()); } + // }}} + // {{{ getUsername() + /** * Proxy call to auth * @see Auth::getUsername() */ - function getUsername() { + function getUsername() + { return($this->auth->getUsername()); } + // }}} + // {{{ getStatus() + /** * Proxy call to auth * @see Auth::getStatus() */ - function getStatus(){ + function getStatus() + { return($this->auth->getStatus()); } + // }}} } http://cvs.php.net/viewcvs.cgi/pear/Auth/Container/DB.php?r1=1.57&r2=1.58&diff_format=u Index: pear/Auth/Container/DB.php diff -u pear/Auth/Container/DB.php:1.57 pear/Auth/Container/DB.php:1.58 --- pear/Auth/Container/DB.php:1.57 Tue Feb 21 23:37:02 2006 +++ pear/Auth/Container/DB.php Tue Feb 28 02:19:22 2006 @@ -1,5 +1,5 @@ <?php -// +/* vim: set expandtab tabstop=4 shiftwidth=4: */ // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ @@ -16,7 +16,7 @@ // | Authors: Martin Jansen <mj@php.net> | // +----------------------------------------------------------------------+ // -// $Id: DB.php,v 1.57 2006/02/21 23:37:02 aashley Exp $ +// $Id: DB.php,v 1.58 2006/02/28 02:19:22 aashley Exp $ // require_once 'Auth/Container.php'; @@ -29,12 +29,15 @@ * by the PEAR DB abstraction layer to fetch login data. * * @author Martin Jansen <mj@php.net> + * @author Adam Ashley <aashley@php.net> * @package Auth - * @version $Revision: 1.57 $ + * @version $Revision: 1.58 $ */ class Auth_Container_DB extends Auth_Container { + // {{{ properties + /** * Additional options for the storage container * @var array @@ -54,12 +57,15 @@ */ var $activeUser = ''; - // {{{ Constructor + // }}} + + // {{{ Auth_Container_DB [constructor] /** * Constructor of the container class * - * Initate connection to the database via PEAR::DB + * Save the initial options passed to the container. Initiation of the DB + * connection is no longer performed here and is only done when needed. * * @param string Connection data or DB object * @return object Returns an error object if something went wrong @@ -157,6 +163,9 @@ return $this->db->query($query); } + // }}} + // {{{ _setDefaults() + /** * Set some default options * @@ -174,6 +183,9 @@ $this->options['db_options'] = array(); } + // }}} + // {{{ _parseOptions() + /** * Parse options passed to the container class * @@ -197,6 +209,9 @@ } } + // }}} + // {{{ fetchData() + /** * Get user information from database * @@ -215,7 +230,6 @@ */ function fetchData($username, $password, $isChallengeResponse=false) { - //print "Container_DB::fetchData($username, $password, $isChallengeResponse) <br/>\n"; // Prepare for a database query $err = $this->_prepare(); if ($err !== true) { @@ -225,8 +239,7 @@ // Find if db_fields contains a *, if so assume all columns are selected if (strstr($this->options['db_fields'], '*')) { $sql_from = "*"; - } - else{ + } else { $sql_from = $this->options['usernamecol'] . ", ".$this->options['passwordcol'].$this->options['db_fields']; } /* @@ -249,12 +262,11 @@ " WHERE ".$this->options['usernamecol']." = ".$this->db->quoteSmart($username); $res = $this->db->getRow($query, null, DB_FETCHMODE_ASSOC); - #print "SQL: $query <br/>\n"; - #print_r($res); if (DB::isError($res)) { return PEAR::raiseError($res->getMessage(), $res->getCode()); } + if (!is_array($res)) { $this->activeUser = ''; return false; @@ -263,15 +275,20 @@ // Perform trimming here before the hashihg $password = trim($password, "\r\n"); $res[$this->options['passwordcol']] = trim($res[$this->options['passwordcol']], "\r\n"); + // If using Challenge Response md5 the pass with the secret if ($isChallengeResponse) { - $res[$this->options['passwordcol']] = md5($res[$this->options['passwordcol']].$this->_auth_obj->session['loginchallenege']); + $res[$this->options['passwordcol']] = md5($res[$this->options['passwordcol']] + .$this->_auth_obj->session['loginchallenege']); + // UGLY cannot avoid without modifying verifyPassword if ($this->options['cryptType'] == 'md5') { $res[$this->options['passwordcol']] = md5($res[$this->options['passwordcol']]); } + //print " Hashed Password [{$res[$this->options['passwordcol']]}]<br/>\n"; } + if ($this->verifyPassword($password, $res[$this->options['passwordcol']], $this->options['cryptType'])) { @@ -282,7 +299,8 @@ continue; } // Use reference to the auth object if exists - // This is because the auth session variable can change so a static call to setAuthData does not make sence + // This is because the auth session variable can change so a + // static call to setAuthData does not make sence $this->_auth_obj->setAuthData($key, $value); } return true; @@ -291,6 +309,9 @@ return false; } + // }}} + // {{{ listUsers() + /** * Returns a list of users from the container * @@ -330,6 +351,9 @@ return $retVal; } + // }}} + // {{{ addUser() + /** * Add user to the storage container * @@ -347,9 +371,11 @@ return PEAR::raiseError($err->getMessage(), $err->getCode()); } - if (isset($this->options['cryptType']) && $this->options['cryptType'] == 'none') { + if ( isset($this->options['cryptType']) + && $this->options['cryptType'] == 'none') { $cryptFunction = 'strval'; - } elseif (isset($this->options['cryptType']) && function_exists($this->options['cryptType'])) { + } elseif ( isset($this->options['cryptType']) + && function_exists($this->options['cryptType'])) { $cryptFunction = $this->options['cryptType']; } else { $cryptFunction = 'md5'; @@ -363,7 +389,7 @@ if (is_array($additional)) { foreach ($additional as $key => $value) { $additional_key .= ', ' . $key; - $additional_value .= ", '" . $value . "'"; + $additional_value .= ", " . $this->db->quoteSmart($value); } } @@ -386,6 +412,9 @@ } } + // }}} + // {{{ removeUser() + /** * Remove user from the storage container * @@ -416,6 +445,9 @@ } } + // }}} + // {{{ changePassword() + /** * Change password for user in the storage container * @@ -429,9 +461,11 @@ return PEAR::raiseError($err->getMessage(), $err->getCode()); } - if (isset($this->options['cryptType']) && $this->options['cryptType'] == 'none') { + if ( isset($this->options['cryptType']) + && $this->options['cryptType'] == 'none') { $cryptFunction = 'strval'; - } elseif (isset($this->options['cryptType']) && function_exists($this->options['cryptType'])) { + } elseif ( isset($this->options['cryptType']) + && function_exists($this->options['cryptType'])) { $cryptFunction = $this->options['cryptType']; } else { $cryptFunction = 'md5'; @@ -456,6 +490,9 @@ } } + // }}} + // {{{ supportsChallengeResponse() + /** * Determine if this container supports * password authentication with challenge response @@ -468,6 +505,9 @@ return in_array($this->options['cryptType'], array('md5', 'none', '')); } + // }}} + // {{{ getCryptType() + /** * Returns the selected crypt type for this container */ @@ -476,5 +516,7 @@ return($this->options['cryptType']); } + // }}} + } ?> http://cvs.php.net/viewcvs.cgi/pear/Auth/Container/DBLite.php?r1=1.4&r2=1.5&diff_format=u Index: pear/Auth/Container/DBLite.php diff -u pear/Auth/Container/DBLite.php:1.4 pear/Auth/Container/DBLite.php:1.5 --- pear/Auth/Container/DBLite.php:1.4 Sun Jan 8 11:54:11 2006 +++ pear/Auth/Container/DBLite.php Tue Feb 28 02:19:22 2006 @@ -1,5 +1,5 @@ <?php -// +/* vim: set expandtab tabstop=4 shiftwidth=4: */ // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ @@ -16,7 +16,7 @@ // | Authors: Martin Jansen <mj@php.net> | // +----------------------------------------------------------------------+ // -// $Id: DBLite.php,v 1.4 2006/01/08 11:54:11 lsmith Exp $ +// $Id: DBLite.php,v 1.5 2006/02/28 02:19:22 aashley Exp $ // require_once 'Auth/Container.php'; @@ -30,12 +30,15 @@ * by the PEAR DB abstraction layer to fetch login data. * * @author Martin Jansen <mj@php.net> + * @author Adam Ashley <aashley@php.net> * @package Auth - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ class Auth_Container_DBLite extends Auth_Container { + // {{{ properties + /** * Additional options for the storage container * @var array @@ -55,7 +58,9 @@ */ var $activeUser = ''; - // {{{ Constructor + // }}} + + // {{{ Auth_Container_DBLite() [constructor] /** * Constructor of the container class @@ -85,6 +90,9 @@ } } + // }}} + // {{{ _connect() + /** * Connect to database by using the given DSN string * @@ -109,6 +117,9 @@ } } + // }}} + // {{{ _prepare() + /** * Prepare database connection * @@ -118,7 +129,8 @@ * @access private * @return mixed True or a DB error object. */ - function _prepare() { + function _prepare() + { if (!DB::isConnection($this->db)) { $res = $this->_connect($this->options['dsn']); if (DB::isError($res) || PEAR::isError($res)) { @@ -128,13 +140,17 @@ return true; } + // }}} + // {{{ _parseOptions() + /** * Parse options passed to the container class * * @access private * @param array */ - function _parseOptions($array) { + function _parseOptions($array) + { foreach ($array as $key => $value) { if (isset($this->options[$key])) { $this->options[$key] = $value; @@ -150,6 +166,9 @@ } } + // }}} + // {{{ fetchData() + /** * Get user information from database * @@ -174,14 +193,13 @@ // Find if db_fields contains a *, if so assume all col are selected if (strstr($this->options['db_fields'], '*')) { $sql_from = "*"; - } - else{ + } else { $sql_from = $this->options['usernamecol'] . ", ".$this->options['passwordcol'].$this->options['db_fields']; } $query = "SELECT ".$sql_from. " FROM ".$this->options['table']. - " WHERE ".$this->options['usernamecol']." = '".$this->db->quoteString($username)."'"; + " WHERE ".$this->options['usernamecol']." = ".$this->db->quoteSmart($username); $res = $this->db->getRow($query, null, DB_FETCHMODE_ASSOC); if (DB::isError($res)) { @@ -214,5 +232,8 @@ $this->activeUser = $res[$this->options['usernamecol']]; return false; } + + // }}} + } ?> http://cvs.php.net/viewcvs.cgi/pear/Auth/Container/File.php?r1=1.17&r2=1.18&diff_format=u Index: pear/Auth/Container/File.php diff -u pear/Auth/Container/File.php:1.17 pear/Auth/Container/File.php:1.18 --- pear/Auth/Container/File.php:1.17 Mon Jan 17 12:54:29 2005 +++ pear/Auth/Container/File.php Tue Feb 28 02:19:22 2006 @@ -18,7 +18,7 @@ // | Mika Tuupola <tuupola@appelsiini.net> | // +----------------------------------------------------------------------+ // -// $Id: File.php,v 1.17 2005/01/17 12:54:29 mike Exp $ +// $Id: File.php,v 1.18 2006/02/28 02:19:22 aashley Exp $ // require_once "File/Passwd.php"; @@ -33,10 +33,13 @@ * @author Stefan Ekman <stekman@sedata.org> * @author Michael Wallner <mike@php.net> * @package Auth - * @version $Revision: 1.17 $ + * @version $Revision: 1.18 $ */ class Auth_Container_File extends Auth_Container { + + // {{{ properties + /** * Path to passwd file * @@ -44,7 +47,9 @@ */ var $pwfile = ''; - // {{{ Constructor + // }}} + + // {{{ Auth_Container_File() [constructor] /** * Constructor of the container class @@ -155,7 +160,6 @@ return false; } - $res = $pw_obj->delUser($user); if (PEAR::isError($res)) { return false; @@ -228,5 +232,6 @@ } // }}} + } ?> http://cvs.php.net/viewcvs.cgi/pear/Auth/Container/IMAP.php?r1=1.10&r2=1.11&diff_format=u Index: pear/Auth/Container/IMAP.php diff -u pear/Auth/Container/IMAP.php:1.10 pear/Auth/Container/IMAP.php:1.11 --- pear/Auth/Container/IMAP.php:1.10 Fri Feb 17 13:25:00 2006 +++ pear/Auth/Container/IMAP.php Tue Feb 28 02:19:22 2006 @@ -1,5 +1,5 @@ <?php -// +/* vim: set expandtab tabstop=4 shiftwidth=4: */ // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ @@ -16,7 +16,7 @@ // | Authors: Jeroen Houben <jeroen@terena.nl> | // +----------------------------------------------------------------------+ // -// $Id: IMAP.php,v 1.10 2006/02/17 13:25:00 moosh Exp $ +// $Id: IMAP.php,v 1.11 2006/02/28 02:19:22 aashley Exp $ // require_once "Auth/Container.php"; @@ -61,32 +61,45 @@ * */ -/* +/** + * Storage driver for fetching login data from a IMAP server * - * @author Jeroen Houben <jeroen@terena.nl>, Cipriano Groenendal <cipri@campai.nl> + * This storage driver authenticates uses against IMAP server. + * + * @author Jeroen Houben <jeroen@terena.nl> + * @author Cipriano Groenendal <cipri@campai.nl> + * @author Adam Ashley <aashley@php.net> * @package Auth - * @version $Revision: 1.10 $ + * @version $Revision: 1.11 $ */ class Auth_Container_IMAP extends Auth_Container { + + // {{{ properties + /** * Options for the class * @var array */ var $options = array(); + // }}} + + // {{{ Auth_Container_IMAP() [constructor] + /** * Constructor of the container class * - * @param $params, associative hash with host,port,basedn and userattr key - * @param $params, associative array with host, port, baseDSN, checkServer key. + * @param $params associative array with host, port, baseDSN, checkServer + * and userattr key * @return object Returns an error object if something went wrong + * @todo Use PEAR Net_IMAP if IMAP extension not loaded */ function Auth_Container_IMAP($params) { if (!extension_loaded('imap')) { - return PEAR::raiseError("Cannot use IMAP authentication, IMAP extension not loaded!", - 41, PEAR_ERROR_DIE); + return PEAR::raiseError('Cannot use IMAP authentication, ' + .'IMAP extension not loaded!', 41); } $this->_setDefaults(); @@ -94,12 +107,16 @@ if (is_array($params)) { $this->_parseOptions($params); } + if ($this->options['checkServer']) { $this->_checkServer($this->options['timeout']); } return true; } + // }}} + // {{{ _setDefaults() + /** * Set some default options * @@ -114,6 +131,8 @@ $this->options['timeout'] = 20; } + // }}} + // {{{ _checkServer() /** * Check if the given server and port are reachable @@ -129,10 +148,13 @@ $message = "Error connecting to IMAP server " . $this->options['host'] . ":" . $this->options['port']; - return PEAR::raiseError($message, 41, PEAR_ERROR_DIE); + return PEAR::raiseError($message, 41); } } + // }}} + // {{{ _parseOptions() + /** * Parse options passed to the container class * @@ -146,6 +168,9 @@ } } + // }}} + // {{{ fetchData() + /** * Try to open a IMAP stream using $username / $password * @@ -166,5 +191,8 @@ return false; } } + + // }}} + } -?> \ No newline at end of file +?> http://cvs.php.net/viewcvs.cgi/pear/Auth/Container/MDB.php?r1=1.21&r2=1.22&diff_format=u Index: pear/Auth/Container/MDB.php diff -u pear/Auth/Container/MDB.php:1.21 pear/Auth/Container/MDB.php:1.22 --- pear/Auth/Container/MDB.php:1.21 Wed Feb 22 00:14:51 2006 +++ pear/Auth/Container/MDB.php Tue Feb 28 02:19:22 2006 @@ -1,5 +1,5 @@ <?php -// +/* vim: set expandtab tabstop=4 shiftwidth=4: */ // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ @@ -16,7 +16,7 @@ // | Author: Lorenzo Alberton <l.alberton@quipo.it> | // +----------------------------------------------------------------------+ // -// $Id: MDB.php,v 1.21 2006/02/22 00:14:51 aashley Exp $ +// $Id: MDB.php,v 1.22 2006/02/28 02:19:22 aashley Exp $ // require_once 'Auth/Container.php'; @@ -29,12 +29,15 @@ * by the PEAR MDB abstraction layer to fetch login data. * * @author Lorenzo Alberton <l.alberton@quipo.it> + * @author Adam Ashley <aashley@php.net> * @package Auth - * @version $Revision: 1.21 $ + * @version $Revision: 1.22 $ */ class Auth_Container_MDB extends Auth_Container { + // {{{ properties + /** * Additional options for the storage container * @var array @@ -54,7 +57,9 @@ */ var $activeUser = ''; - // {{{ Constructor + // }}} + + // {{{ Auth_Container_MDB() [constructor] /** * Constructor of the container class @@ -256,6 +261,7 @@ // Perform trimming here before the hashing $password = trim($password, "\r\n"); $res[$this->options['passwordcol']] = trim($res[$this->options['passwordcol']], "\r\n"); + // If using Challenge Response md5 the pass with the secret if ($isChallengeResponse) { $res[$this->options['passwordcol']] = @@ -265,6 +271,7 @@ $res[$this->options['passwordcol']] = md5($res[$this->options['passwordcol']]); } } + if ($this->verifyPassword($password, $res[$this->options['passwordcol']], $this->options['cryptType'])) { @@ -275,7 +282,8 @@ continue; } // Use reference to the auth object if exists - // This is because the auth session variable can change so a static call to setAuthData does not make sense + // This is because the auth session variable can change so a static + // call to setAuthData does not make sense $this->_auth_obj->setAuthData($key, $value); } return true; http://cvs.php.net/viewcvs.cgi/pear/Auth/Container/MDB2.php?r1=1.7&r2=1.8&diff_format=u Index: pear/Auth/Container/MDB2.php diff -u pear/Auth/Container/MDB2.php:1.7 pear/Auth/Container/MDB2.php:1.8 --- pear/Auth/Container/MDB2.php:1.7 Wed Feb 22 00:14:51 2006 +++ pear/Auth/Container/MDB2.php Tue Feb 28 02:19:22 2006 @@ -1,5 +1,5 @@ <?php -// +/* vim: set expandtab tabstop=4 shiftwidth=4: */ // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ @@ -16,7 +16,7 @@ // | Author: Lorenzo Alberton <l.alberton@quipo.it> | // +----------------------------------------------------------------------+ // -// $Id: MDB2.php,v 1.7 2006/02/22 00:14:51 aashley Exp $ +// $Id: MDB2.php,v 1.8 2006/02/28 02:19:22 aashley Exp $ // require_once 'Auth/Container.php'; @@ -29,12 +29,15 @@ * by the PEAR MDB2 abstraction layer to fetch login data. * * @author Lorenzo Alberton <l.alberton@quipo.it> + * @author Adam Ashley <aashley@php.net> * @package Auth - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ */ class Auth_Container_MDB2 extends Auth_Container { + // {{{ properties + /** * Additional options for the storage container * @var array @@ -54,7 +57,9 @@ */ var $activeUser = ''; - // {{{ Constructor + // }}} + + // {{{ Auth_Container_MDB2() [constructor] /** * Constructor of the container class http://cvs.php.net/viewcvs.cgi/pear/Auth/Container/PEAR.php?r1=1.3&r2=1.4&diff_format=u Index: pear/Auth/Container/PEAR.php diff -u pear/Auth/Container/PEAR.php:1.3 pear/Auth/Container/PEAR.php:1.4 --- pear/Auth/Container/PEAR.php:1.3 Sun Mar 28 23:19:50 2004 +++ pear/Auth/Container/PEAR.php Tue Feb 28 02:19:22 2006 @@ -1,17 +1,73 @@ <?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2003 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 2.02 of the PHP license, | +// | that is bundled with this package in the file LICENSE, and is | +// | available at through the world-wide-web at | +// | http://www.php.net/license/2_02.txt. | +// | If you did not receive a copy of the PHP license and are unable to | +// | obtain it through the world-wide-web, please send a note to | +// | license@php.net so we can mail you a copy immediately. | +// +----------------------------------------------------------------------+ +// | Authors: Martin Jansen <mj@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: PEAR.php,v 1.4 2006/02/28 02:19:22 aashley Exp $ +// -include_once('XML/RPC.php'); +/** Include PEAR XML_RPC */ +require_once('XML/RPC.php'); -class Auth_Container_Pear { - function Auth_Container_pear() +/** + * Storage driver for authenticating against PEAR website + * + * This driver provides a method for authenticating against the pear.php.net + * authentication system. + * + * @author Yavor Shahpasov <yavo@netsmart.com.cy> + * @author Adam Ashley <aashley@php.net> + * @package Auth + * @version $Revision: 1.4 $ + */ +class Auth_Container_Pear +{ + + // {{{ Auth_Container_Pear() [constructor] + + /** + * Constructor + * + * Currently does nothing + * + * @return void + */ + function Auth_Container_Pear() { } + + // }}} + // {{{ fetchData() + /** + * Get user information from pear.php.net + * + * This function uses the given username and password to authenticate + * against the pear.php.net website + * + * @param string Username + * @param string Password + * @return mixed Error object or boolean + */ function fetchData($username, $password) { $rpc = new XML_RPC_Client('/xmlrpc.php', 'pear.php.net'); $rpc_message = new XML_RPC_Message("user.info", array(new XML_RPC_Value($username, "string")) ); + // Error Checking howto ??? $result = $rpc->send($rpc_message); $value = $result->value(); @@ -25,6 +81,8 @@ } return false; } + + // }}} } -?> \ No newline at end of file +?> http://cvs.php.net/viewcvs.cgi/pear/Auth/Container/POP3.php?r1=1.5&r2=1.6&diff_format=u Index: pear/Auth/Container/POP3.php diff -u pear/Auth/Container/POP3.php:1.5 pear/Auth/Container/POP3.php:1.6 --- pear/Auth/Container/POP3.php:1.5 Tue Feb 21 05:26:31 2006 +++ pear/Auth/Container/POP3.php Tue Feb 28 02:19:22 2006 @@ -18,23 +18,25 @@ // | Mika Tuupola <tuupola@appelsiini.net> | // +----------------------------------------------------------------------+ // -// $Id: POP3.php,v 1.5 2006/02/21 05:26:31 aashley Exp $ +// $Id: POP3.php,v 1.6 2006/02/28 02:19:22 aashley Exp $ // - -require_once('Auth/Container.php'); -require_once('PEAR.php'); -require_once('Net/POP3.php'); +require_once 'Auth/Container.php'; +require_once 'PEAR.php'; +require_once 'Net/POP3.php'; /** * Storage driver for Authentication on a POP3 server. * * @author Yavor Shahpasov <yavo@netsmart.com.cy> * @package Auth - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ */ class Auth_Container_POP3 extends Auth_Container { + + // {{{ properties + /** * POP3 Server * @var string @@ -59,7 +61,9 @@ */ var $method=true; - // {{{ Constructor + // }}} + + // {{{ Auth_Container_POP3() [constructor] /** * Constructor of the container class @@ -115,5 +119,6 @@ } // }}} + } ?> http://cvs.php.net/viewcvs.cgi/pear/Auth/Container/RADIUS.php?r1=1.8&r2=1.9&diff_format=u Index: pear/Auth/Container/RADIUS.php diff -u pear/Auth/Container/RADIUS.php:1.8 pear/Auth/Container/RADIUS.php:1.9 --- pear/Auth/Container/RADIUS.php:1.8 Mon Dec 6 07:56:24 2004 +++ pear/Auth/Container/RADIUS.php Tue Feb 28 02:19:22 2006 @@ -1,5 +1,5 @@ <?php -// +/* vim: set expandtab tabstop=4 shiftwidth=4: */ // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ @@ -16,7 +16,7 @@ // | Authors: Michael Bretterklieber <michael@bretterklieber.com> | // +----------------------------------------------------------------------+ // -// $Id: RADIUS.php,v 1.8 2004/12/06 07:56:24 yavo Exp $ +// $Id: RADIUS.php,v 1.9 2006/02/28 02:19:22 aashley Exp $ // require_once "Auth/Container.php"; @@ -26,12 +26,15 @@ * Storage driver for authenticating users against RADIUS servers. * * @author Michael Bretterklieber <michael@bretterklieber.com> + * @author Adam Ashley <aashley@php.net> * @access public - * @version $Revision: 1.8 $ + * @version $Revision: 1.9 $ */ class Auth_Container_RADIUS extends Auth_Container { + // {{{ properties + /** * Contains a RADIUS object * @var object @@ -44,6 +47,10 @@ */ var $authtype; + // }}} + + // {{{ Auth_Container_RADIUS() [constructor] + /** * Constructor of the container class. * @@ -65,8 +72,8 @@ } $classname = 'Auth_RADIUS_' . $this->authtype; if (!class_exists($classname)) { - PEAR::raiseError("Unknown Authtype, please use on of: PAP, CHAP_MD5, MSCHAPv1, MSCHAPv2!", - 41, PEAR_ERROR_DIE); + PEAR::raiseError("Unknown Authtype, please use on of: " + ."PAP, CHAP_MD5, MSCHAPv1, MSCHAPv2!", 41, PEAR_ERROR_DIE); } $this->radius = new $classname; @@ -92,6 +99,9 @@ } } + // }}} + // {{{ fetchData() + /** * Authenticate * @@ -150,5 +160,8 @@ return $result; } + + // }}} + } ?> http://cvs.php.net/viewcvs.cgi/pear/Auth/Container/SMBPasswd.php?r1=1.2&r2=1.3&diff_format=u Index: pear/Auth/Container/SMBPasswd.php diff -u pear/Auth/Container/SMBPasswd.php:1.2 pear/Auth/Container/SMBPasswd.php:1.3 --- pear/Auth/Container/SMBPasswd.php:1.2 Sun Mar 28 23:19:50 2004 +++ pear/Auth/Container/SMBPasswd.php Tue Feb 28 02:19:22 2006 @@ -16,7 +16,7 @@ // | Authors: Michael Bretterklieber <michael@bretterklieber.com> | // +----------------------------------------------------------------------+ // -// $Id: SMBPasswd.php,v 1.2 2004/03/28 23:19:50 yavo Exp $ +// $Id: SMBPasswd.php,v 1.3 2006/02/28 02:19:22 aashley Exp $ // require_once "File/SMBPasswd.php"; @@ -37,18 +37,24 @@ * } * * @author Michael Bretterklieber <michael@bretterklieber.com> + * @author Adam Ashley <aashley@php.net> * @package Auth - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ class Auth_Container_SMBPasswd extends Auth_Container { + + // {{{ properties + /** * File_SMBPasswd object * @var object */ var $pwfile; - // {{{ Constructor + // }}} + + // {{{ Auth_Container_SMBPasswd() [constructor] /** * Constructor of the container class http://cvs.php.net/viewcvs.cgi/pear/Auth/Container/SOAP.php?r1=1.7&r2=1.8&diff_format=u Index: pear/Auth/Container/SOAP.php diff -u pear/Auth/Container/SOAP.php:1.7 pear/Auth/Container/SOAP.php:1.8 --- pear/Auth/Container/SOAP.php:1.7 Wed Feb 16 09:06:47 2005 +++ pear/Auth/Container/SOAP.php Tue Feb 28 02:19:22 2006 @@ -1,5 +1,5 @@ <?php -// +/* vim: set expandtab tabstop=4 shiftwidth=4: */ // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ @@ -16,7 +16,7 @@ // | Authors: Bruno Pedro <bpedro@co.sapo.pt> | // +----------------------------------------------------------------------+ // -// $Id: SOAP.php,v 1.7 2005/02/16 09:06:47 yavo Exp $ +// $Id: SOAP.php,v 1.8 2006/02/28 02:19:22 aashley Exp $ // require_once "Auth/Container.php"; @@ -65,18 +65,28 @@ * ?> * * @author Bruno Pedro <bpedro@co.sapo.pt> + * @author Adam Ashley <aashley@php.net> * @package Auth - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ */ class Auth_Container_SOAP extends Auth_Container { + // {{{ properties + /** * Required options for the class * @var array * @access private */ - var $_requiredOptions = array('endpoint', 'namespace', 'method', 'encoding', 'usernamefield', 'passwordfield'); + var $_requiredOptions = array( + 'endpoint', + 'namespace', + 'method', + 'encoding', + 'usernamefield', + 'passwordfield', + ); /** * Options for the class @@ -106,6 +116,10 @@ */ var $soapClient = null; + // }}} + + // {{{ Auth_Container_SOAP() [constructor] + /** * Constructor of the container class * @@ -124,6 +138,9 @@ } } + // }}} + // {{{ fetchData() + /** * Fetch data from SOAP service * @@ -144,28 +161,34 @@ $this->soapClient = new SOAP_Client($this->_options['endpoint']); $this->soapClient->setEncoding($this->_options['encoding']); } + // set the trace option if requested if (isset($this->_options['trace'])) { $this->soapClient->__options['trace'] = true; } + // set the timeout option if requested if (isset($this->_options['timeout'])) { $this->soapClient->__options['timeout'] = $this->_options['timeout']; } + // assign username and password fields $usernameField = new SOAP_Value($this->_options['usernamefield'],'string', $username); $passwordField = new SOAP_Value($this->_options['passwordfield'],'string', $password); $SOAPParams = array($usernameField, $passwordField); + // assign optional features foreach ($this->_features as $fieldName => $fieldValue) { $SOAPParams[] = new SOAP_Value($fieldName, 'string', $fieldValue); } + // make SOAP call $this->soapResponse = $this->soapClient->call( - $this->_options['method'], - $SOAPParams, - array('namespace' => $this->_options['namespace']) - ); + $this->_options['method'], + $SOAPParams, + array('namespace' => $this->_options['namespace']) + ); + if (!PEAR::isError($this->soapResponse)) { if ($this->_options['matchpasswords']) { // check if passwords match @@ -181,5 +204,8 @@ return false; } } + + // }}} + } ?> http://cvs.php.net/viewcvs.cgi/pear/Auth/Container/vpopmail.php?r1=1.3&r2=1.4&diff_format=u Index: pear/Auth/Container/vpopmail.php diff -u pear/Auth/Container/vpopmail.php:1.3 pear/Auth/Container/vpopmail.php:1.4 --- pear/Auth/Container/vpopmail.php:1.3 Mon Sep 8 11:24:05 2003 +++ pear/Auth/Container/vpopmail.php Tue Feb 28 02:19:22 2006 @@ -16,7 +16,7 @@ // | Author: Stanislav Grozev <tacho@orbitel.bg> | // +----------------------------------------------------------------------+ // -// $Id: vpopmail.php,v 1.3 2003/09/08 11:24:05 yavo Exp $ +// $Id: vpopmail.php,v 1.4 2006/02/28 02:19:22 aashley Exp $ // require_once "Auth/Container.php"; @@ -25,8 +25,9 @@ * Storage driver for fetching login data from vpopmail * * @author Stanislav Grozev <tacho@orbitel.bg> + * @author Adam Ashley <aashley@php.net> * @package Auth - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ */ class Auth_Container_vpopmail extends Auth_Container { @@ -62,5 +63,6 @@ } // }}} + } ?> http://cvs.php.net/viewcvs.cgi/pear/Auth/Frontend/Html.php?r1=1.5&r2=1.6&diff_format=u Index: pear/Auth/Frontend/Html.php diff -u pear/Auth/Frontend/Html.php:1.5 pear/Auth/Frontend/Html.php:1.6 --- pear/Auth/Frontend/Html.php:1.5 Sun Jan 8 12:42:37 2006 +++ pear/Auth/Frontend/Html.php Tue Feb 28 02:19:22 2006 @@ -1,44 +1,76 @@ <?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2003 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 2.02 of the PHP license, | +// | that is bundled with this package in the file LICENSE, and is | +// | available at through the world-wide-web at | +// | http://www.php.net/license/2_02.txt. | +// | If you did not receive a copy of the PHP license and are unable to | +// | obtain it through the world-wide-web, please send a note to | +// | license@php.net so we can mail you a copy immediately. | +// +----------------------------------------------------------------------+ +// | Authors: Martin Jansen <mj@php.net> | +// +----------------------------------------------------------------------+ +// +// $Id: Html.php,v 1.6 2006/02/28 02:19:22 aashley Exp $ +// + /** - * Standard Html Login form - * - */ + * Standard Html Login form + * + * @author Yavor Shahpasov <yavo@netsmart.com.cy> + * @author Adam Ashley <aashley@php.net> + * @package Auth + * @version $Revision: 1.6 $ + */ class Auth_Frontend_Html { + + // {{{ render() /** - * Displays the login form - * - * @param object The calling auth instance - * @return void - */ + * Displays the login form + * + * @param object The calling auth instance + * @param string The previously used username + * @return void + */ function render(&$caller, $username = '') { $loginOnClick = 'return true;'; + // Try To Use Challene response // TODO javascript might need some improvement for work on other browsers if($caller->advancedsecurity && $caller->storage->supportsChallengeResponse() ) { + // Init the secret cookie $caller->session['loginchallenege'] = md5(microtime()); - //$caller->session['loginchallenege'] = '1'; - #print 'Using Challenge Response '.$caller->session['loginchallenege'].'<br/>'; + print "\n"; print '<script language="JavaScript">'."\n"; + // This is ugly, better sugestions send them to me - include(dirname(__FILE__).'/md5.js'); + include 'Auth/Frontend/md5.js'; + print "\n"; print ' function securePassword() { '."\n"; print ' var pass = document.getElementById(\''.$caller->getPostPasswordField().'\');'."\n"; print ' var secret = document.getElementById(\'authsecret\')'."\n"; - #print ' alert(pass);alert(secret); '."\n"; + //print ' alert(pass);alert(secret); '."\n"; + // If using md5 for password storage md5 the password before // we hash it with the secret - #print ' alert(pass.value);'; + // print ' alert(pass.value);'; if ($caller->storage->getCryptType() == 'md5' ) { print ' pass.value = hex_md5(pass.value); '."\n"; #print ' alert(pass.value);'; } + print ' pass.value = hex_md5(pass.value+\''.$caller->session['loginchallenege'].'\'); '."\n"; - #print ' alert(pass.value);'; + // print ' alert(pass.value);'; print ' secret.value = 1;'."\n"; print ' var doLogin = document.getElementById(\'doLogin\')'."\n"; print ' doLogin.disabled = true;'."\n"; @@ -46,9 +78,11 @@ print ' } '."\n"; print '</script>'."\n";; print "\n"; + $loginOnClick = ' return securePassword(); '; } - echo '<center>'."\n"; + + print '<center>'."\n"; $status = ''; if (!empty($caller->status) && $caller->status == AUTH_EXPIRED) { @@ -61,29 +95,39 @@ $status = '<i>Security problem detected. </i>'."\n"; } - echo '<form method="post" action="'.$caller->server['PHP_SELF'].'" onSubmit="'.$loginOnClick.'">'."\n"; - echo '<table border="0" cellpadding="2" cellspacing="0" summary="login form" align="center" >'."\n"; - echo '<tr>'."\n"; - echo ' <td colspan="2" bgcolor="#eeeeee"><strong>Login </strong>'.$status.'</td>'."\n"; - echo '</tr>'."\n"; - echo '<tr>'."\n"; - echo ' <td>Username:</td>'."\n"; - echo ' <td><input type="text" id="'.$caller->getPostUsernameField().'" name="'.$caller->getPostUsernameField().'" value="' . $username . '" /></td>'."\n"; - echo '</tr>'."\n"; - echo '<tr>'."\n"; - echo ' <td>Password:</td>'."\n"; - echo ' <td><input type="password" id="'.$caller->getPostPasswordField().'" name="'.$caller->getPostPasswordField().'" /></td>'."\n"; - echo '</tr>'."\n"; - echo '<tr>'."\n"; + print '<form method="post" action="'.$caller->server['PHP_SELF'].'" ' + .'onSubmit="'.$loginOnClick.'">'."\n"; + print '<table border="0" cellpadding="2" cellspacing="0" ' + .'summary="login form" align="center" >'."\n"; + print '<tr>'."\n"; + print ' <td colspan="2" bgcolor="#eeeeee"><strong>Login </strong>' + .$status.'</td>'."\n"; + print '</tr>'."\n"; + print '<tr>'."\n"; + print ' <td>Username:</td>'."\n"; + print ' <td><input type="text" id="'.$caller->getPostUsernameField() + .'" name="'.$caller->getPostUsernameField().'" value="' . $username + .'" /></td>'."\n"; + print '</tr>'."\n"; + print '<tr>'."\n"; + print ' <td>Password:</td>'."\n"; + print ' <td><input type="password" id="'.$caller->getPostPasswordField() + .'" name="'.$caller->getPostPasswordField().'" /></td>'."\n"; + print '</tr>'."\n"; + print '<tr>'."\n"; //onClick=" '.$loginOnClick.' " - echo ' <td colspan="2" bgcolor="#eeeeee"><input value="Login" id="doLogin" name="doLogin" type="submit" /></td>'."\n"; - echo '</tr>'."\n"; - echo '</table>'."\n"; + print ' <td colspan="2" bgcolor="#eeeeee"><input value="Login" ' + .'id="doLogin" name="doLogin" type="submit" /></td>'."\n"; + print '</tr>'."\n"; + print '</table>'."\n"; + // Might be a good idea to make the variable name variable - echo '<input type="hidden" id="authsecret" name="authsecret" value="" />'; - echo '</form>'."\n"; + print '<input type="hidden" id="authsecret" name="authsecret" value="" />'; + print '</form>'."\n"; } + + // }}} } http://cvs.php.net/viewcvs.cgi/pear/Auth/tests/DBContainer.php?r1=1.1&r2=1.2&diff_format=u Index: pear/Auth/tests/DBContainer.php diff -u pear/Auth/tests/DBContainer.php:1.1 pear/Auth/tests/DBContainer.php:1.2 --- pear/Auth/tests/DBContainer.php:1.1 Sat Jul 19 17:58:15 2003 +++ pear/Auth/tests/DBContainer.php Tue Feb 28 02:19:22 2006 @@ -1,7 +1,7 @@ <?php -include_once('TestAuthContainer.php'); -include_once("Auth/Container/DB.php"); +include_once 'TestAuthContainer.php'; +include_once 'Auth/Container/DB.php'; class DBContainer extends TestAuthContainer { @@ -14,7 +14,7 @@ static $container; #print "In DBContainer::getContainer {$this->skip_tests}\n"; if(!isset($container)){ - include('./auth_container_db_options.php'); + include './auth_container_db_options.php'; $container = new Auth_Container_DB($options); // Catch if DB connection cannot be made $res = $container->_prepare(); @@ -29,7 +29,7 @@ } function &getExtraOptions() { - include('./auth_container_db_options.php'); + include './auth_container_db_options.php'; return($extra_options); } } @@ -37,4 +37,4 @@ -?> \ No newline at end of file +?> http://cvs.php.net/viewcvs.cgi/pear/Auth/tests/DBLiteContainer.php?r1=1.1&r2=1.2&diff_format=u Index: pear/Auth/tests/DBLiteContainer.php diff -u pear/Auth/tests/DBLiteContainer.php:1.1 pear/Auth/tests/DBLiteContainer.php:1.2 --- pear/Auth/tests/DBLiteContainer.php:1.1 Mon Oct 11 11:23:23 2004 +++ pear/Auth/tests/DBLiteContainer.php Tue Feb 28 02:19:22 2006 @@ -1,7 +1,7 @@ <?php -include_once('TestAuthContainer.php'); -include_once("Auth/Container/DBLite.php"); +include_once 'TestAuthContainer.php'; +include_once 'Auth/Container/DBLite.php'; class DBLiteContainer extends TestAuthContainer { @@ -14,7 +14,7 @@ static $container; #print "In DBContainer::getContainer {$this->skip_tests}\n"; if(!isset($container)){ - include('./auth_container_db_options.php'); + include './auth_container_db_options.php'; $container = new Auth_Container_DBLite($options); // Catch if DB connection cannot be made $res = $container->_prepare(); @@ -29,7 +29,7 @@ } function &getExtraOptions() { - include('./auth_container_db_options.php'); + include './auth_container_db_options.php'; return($extra_options); } } @@ -37,4 +37,4 @@ -?> \ No newline at end of file +?> http://cvs.php.net/viewcvs.cgi/pear/Auth/tests/FileContainer.php?r1=1.1&r2=1.2&diff_format=u Index: pear/Auth/tests/FileContainer.php diff -u pear/Auth/tests/FileContainer.php:1.1 pear/Auth/tests/FileContainer.php:1.2 --- pear/Auth/tests/FileContainer.php:1.1 Sat Jul 19 17:58:15 2003 +++ pear/Auth/tests/FileContainer.php Tue Feb 28 02:19:22 2006 @@ -1,7 +1,7 @@ <?php -include_once('TestAuthContainer.php'); -include_once("Auth/Container/File.php"); +include_once 'TestAuthContainer.php'; +include_once 'Auth/Container/File.php'; class FileContaner extends TestAuthContainer { @@ -12,14 +12,14 @@ function &getContainer() { static $container; if(!isset($container)){ - include('./auth_container_file_options.php'); + include './auth_container_file_options.php'; $container = new Auth_Container_File($options); } return($container); } function &getExtraOptions() { - include('./auth_container_file_options.php'); + include './auth_container_file_options.php'; return($extra_options); } } @@ -27,4 +27,4 @@ -?> \ No newline at end of file +?> http://cvs.php.net/viewcvs.cgi/pear/Auth/tests/IMAPContainer.php?r1=1.2&r2=1.3&diff_format=u Index: pear/Auth/tests/IMAPContainer.php diff -u pear/Auth/tests/IMAPContainer.php:1.2 pear/Auth/tests/IMAPContainer.php:1.3 --- pear/Auth/tests/IMAPContainer.php:1.2 Mon Oct 11 11:23:23 2004 +++ pear/Auth/tests/IMAPContainer.php Tue Feb 28 02:19:22 2006 @@ -1,7 +1,7 @@ <?php -include_once('TestAuthContainer.php'); -include_once("Auth/Container/IMAP.php"); +include_once 'TestAuthContainer.php'; +include_once 'Auth/Container/IMAP.php'; class IMAPContainer extends TestAuthContainer { @@ -14,7 +14,7 @@ print "IMAPContainer::getContainer\n"; static $container; if(!isset($container)){ - include('./auth_container_imap_options.php'); + include './auth_container_imap_options.php'; $container = new Auth_Container_IMAP($options); } return($container); @@ -22,7 +22,7 @@ function &getExtraOptions() { print "IMAPContainer::getExtraOptions\n"; - include('./auth_container_imap_options.php'); + include './auth_container_imap_options.php'; return($extra_options); } } @@ -30,4 +30,4 @@ -?> \ No newline at end of file +?> http://cvs.php.net/viewcvs.cgi/pear/Auth/tests/MDB2Container.php?r1=1.1&r2=1.2&diff_format=u Index: pear/Auth/tests/MDB2Container.php diff -u pear/Auth/tests/MDB2Container.php:1.1 pear/Auth/tests/MDB2Container.php:1.2 --- pear/Auth/tests/MDB2Container.php:1.1 Tue Mar 30 20:12:52 2004 +++ pear/Auth/tests/MDB2Container.php Tue Feb 28 02:19:22 2006 @@ -33,4 +33,4 @@ return $extra_options; } } -?> \ No newline at end of file +?> http://cvs.php.net/viewcvs.cgi/pear/Auth/tests/MDBContainer.php?r1=1.1&r2=1.2&diff_format=u Index: pear/Auth/tests/MDBContainer.php diff -u pear/Auth/tests/MDBContainer.php:1.1 pear/Auth/tests/MDBContainer.php:1.2 --- pear/Auth/tests/MDBContainer.php:1.1 Tue Jul 29 00:07:10 2003 +++ pear/Auth/tests/MDBContainer.php Tue Feb 28 02:19:22 2006 @@ -37,4 +37,4 @@ -?> \ No newline at end of file +?> http://cvs.php.net/viewcvs.cgi/pear/Auth/tests/POP3Container.php?r1=1.1&r2=1.2&diff_format=u Index: pear/Auth/tests/POP3Container.php diff -u pear/Auth/tests/POP3Container.php:1.1 pear/Auth/tests/POP3Container.php:1.2 --- pear/Auth/tests/POP3Container.php:1.1 Sat Jul 19 17:58:15 2003 +++ pear/Auth/tests/POP3Container.php Tue Feb 28 02:19:22 2006 @@ -1,7 +1,7 @@ <?php -include_once('TestAuthContainer.php'); -include_once("Auth/Container/POP3.php"); +include_once 'TestAuthContainer.php'; +include_once 'Auth/Container/POP3.php'; class POP3Container extends TestAuthContainer { @@ -13,14 +13,14 @@ function &getContainer() { static $container; if(!isset($container)){ - include('./auth_container_pop3_options.php'); + include './auth_container_pop3_options.php'; $container = new Auth_Container_POP3($options); } return($container); } function &getExtraOptions() { - include('./auth_container_pop3_options.php'); + include './auth_container_pop3_options.php'; return($extra_options); } } @@ -28,4 +28,4 @@ -?> \ No newline at end of file +?> http://cvs.php.net/viewcvs.cgi/pear/Auth/tests/POP3aContainer.php?r1=1.1&r2=1.2&diff_format=u Index: pear/Auth/tests/POP3aContainer.php diff -u pear/Auth/tests/POP3aContainer.php:1.1 pear/Auth/tests/POP3aContainer.php:1.2 --- pear/Auth/tests/POP3aContainer.php:1.1 Sat Jul 19 17:58:15 2003 +++ pear/Auth/tests/POP3aContainer.php Tue Feb 28 02:19:22 2006 @@ -1,7 +1,7 @@ <?php -include_once('TestAuthContainer.php'); -include_once("Auth/Container/POP3.php"); +include_once 'TestAuthContainer.php'; +include_once 'Auth/Container/POP3.php'; class POP3aContainer extends TestAuthContainer { @@ -13,14 +13,14 @@ function &getContainer() { static $container; if(!isset($container)){ - include('./auth_container_pop3a_options.php'); + include './auth_container_pop3a_options.php'; $container = new Auth_Container_POP3($options); } return($container); } function &getExtraOptions() { - include('./auth_container_pop3a_options.php'); + include './auth_container_pop3a_options.php'; return($extra_options); } } @@ -28,4 +28,4 @@ -?> \ No newline at end of file +?> http://cvs.php.net/viewcvs.cgi/pear/Auth/tests/TestAuthContainer.php?r1=1.6&r2=1.7&diff_format=u Index: pear/Auth/tests/TestAuthContainer.php diff -u pear/Auth/tests/TestAuthContainer.php:1.6 pear/Auth/tests/TestAuthContainer.php:1.7 --- pear/Auth/tests/TestAuthContainer.php:1.6 Mon Oct 11 11:23:23 2004 +++ pear/Auth/tests/TestAuthContainer.php Tue Feb 28 02:19:22 2006 @@ -170,4 +170,4 @@ } -?> \ No newline at end of file +?> http://cvs.php.net/viewcvs.cgi/pear/Auth/tests/auth_container_db_options.php?r1=1.3&r2=1.4&diff_format=u Index: pear/Auth/tests/auth_container_db_options.php diff -u pear/Auth/tests/auth_container_db_options.php:1.3 pear/Auth/tests/auth_container_db_options.php:1.4 --- pear/Auth/tests/auth_container_db_options.php:1.3 Wed Feb 22 00:34:11 2006 +++ pear/Auth/tests/auth_container_db_options.php Tue Feb 28 02:19:23 2006 @@ -13,7 +13,7 @@ 'table'=>'temp', 'usernamecol'=>'username', 'passwordcol'=>'password', - 'cryptType'=>'md5', + 'cryptType'=>'md5', 'db_fields'=>'*' ); http://cvs.php.net/viewcvs.cgi/pear/Auth/tests/auth_container_file_options.php?r1=1.1&r2=1.2&diff_format=u Index: pear/Auth/tests/auth_container_file_options.php diff -u pear/Auth/tests/auth_container_file_options.php:1.1 pear/Auth/tests/auth_container_file_options.php:1.2 --- pear/Auth/tests/auth_container_file_options.php:1.1 Sat Jul 19 17:58:15 2003 +++ pear/Auth/tests/auth_container_file_options.php Tue Feb 28 02:19:23 2006 @@ -5,4 +5,4 @@ $extra_options['username'] = 'test_user'; $extra_options['passwd'] = 'test_user'; -?> \ No newline at end of file +?> http://cvs.php.net/viewcvs.cgi/pear/Auth/tests/tests.php?r1=1.8&r2=1.9&diff_format=u Index: pear/Auth/tests/tests.php diff -u pear/Auth/tests/tests.php:1.8 pear/Auth/tests/tests.php:1.9 --- pear/Auth/tests/tests.php:1.8 Wed Feb 22 00:34:11 2006 +++ pear/Auth/tests/tests.php Tue Feb 28 02:19:23 2006 @@ -1,16 +1,16 @@ <?php -include_once('Auth.php'); -include('TestAuthContainer.php'); -include('FileContainer.php'); -include('DBContainer.php'); -include('DBLiteContainer.php'); -include('MDBContainer.php'); -include('MDB2Container.php'); -include('POP3Container.php'); -include('POP3aContainer.php'); -include('IMAPContainer.php'); -include_once('PHPUnit.php'); +include_once 'Auth.php'; +include_once 'TestAuthContainer.php'; +include_once 'FileContainer.php'; +include_once 'DBContainer.php'; +include_once 'DBLiteContainer.php'; +include_once 'MDBContainer.php'; +include_once 'MDB2Container.php'; +include_once 'POP3Container.php'; +include_once 'POP3aContainer.php'; +include_once 'IMAPContainer.php'; +include_once 'PHPUnit.php'; function error($err){
« previous php.pear.cvs (#38716) next »