From: Michael M Slusarz Date: Wed, 22 Jul 2009 00:21:50 +0000 (-0600) Subject: Always set auth through setAuth(), honor 'login' param to setAuth() X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=9c4e000cb24936f2147efd59534bc9694de6b973;p=horde.git Always set auth through setAuth(), honor 'login' param to setAuth() --- diff --git a/framework/Auth/lib/Horde/Auth.php b/framework/Auth/lib/Horde/Auth.php index c9d317557..db03db098 100644 --- a/framework/Auth/lib/Horde/Auth.php +++ b/framework/Auth/lib/Horde/Auth.php @@ -369,9 +369,10 @@ class Horde_Auth $driver = empty($options['app']) ? $GLOBALS['conf']['auth']['driver'] : $options['app']; + $is_auth = self::getAuth(); /* Check for cached authentication results. */ - if (self::getAuth() && + if ($is_auth && ((isset($_SESSION['horde_auth']['driver']) && $_SESSION['horde_auth']['driver'] == $driver) || isset($_SESSION['horde_auth']['app'][$driver]))) { return self::checkExistingAuth(); @@ -384,9 +385,8 @@ class Horde_Auth /* If we have a horde session, and the app doesn't need additional * auth, mark that in the session and return. */ - if (self::getAuth() && !$auth->hasCapability('authenticate')) { - $_SESSION['horde_auth']['app'][$driver] = true; - return true; + if ($is_auth && !$auth->hasCapability('authenticate')) { + return self::setAuth($is_auth, self::getCredential(), array('app' => $driver)); } } @@ -622,20 +622,23 @@ class Horde_Auth * @param array $options Additional options: *
      * 'app' - (string) The app to set authentication credentials for.
+     *         DEFAULT: Set horde authentication
      * 'change' - (boolean) Whether to request that the user change their
      *            password.
+     *            DEFAULT: No
      * 'login' - (boolean) Do login tasks?
-     *           DEFAULT: TODO
+     *           DEFAULT: True
      * 
* * @return boolean Whether authentication was successful. */ static public function setAuth($userId, $credentials, $options = array()) { + $app = empty($options['app']) ? 'horde' : $options['app']; $userId = self::addHook(trim($userId)); if (!empty($GLOBALS['conf']['hooks']['postauthenticate'])) { - if (Horde::callHook('_horde_hook_postauthenticate', array($userId, $credentials, empty($options['app']) ? 'horde' : $options['app']), 'horde') === false) { + if (Horde::callHook('_horde_hook_postauthenticate', array($userId, $credentials, $app), 'horde') === false) { if (self::getAuthError() != self::REASON_MESSAGE) { self::setAuthError(self::REASON_FAILED); } @@ -643,14 +646,13 @@ class Horde_Auth } } - if (!empty($options['app'])) { - if (!empty($_SESSION['horde_auth'])) { - $_SESSION['horde_auth']['app'][$options['app']] = true; - return true; + $app_array = array(); + if ($app != 'horde') { + if (empty($_SESSION['horde_auth'])) { + $app_array = array($app => true); + } else { + $_SESSION['horde_auth']['app'][$app] = true; } - $app_array = array($options['app'] => true); - } else { - $app_array = array(); } /* If we're already set with this userId, don't continue. */ @@ -671,7 +673,7 @@ class Horde_Auth 'browser' => $browser->getAgentString(), 'change' => !empty($options['change']), 'credentials' => $credentials, - 'driver' => empty($options['app']) ? $GLOBALS['conf']['auth']['driver'] : $options['app'], + 'driver' => ($app == 'horde') ? $GLOBALS['conf']['auth']['driver'] : $app, 'remoteAddr' => isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null, 'timestamp' => time(), 'userId' => $userId @@ -682,6 +684,10 @@ class Horde_Auth $registry->loadPrefs(); Horde_Nls::setLang($GLOBALS['prefs']->getValue('language')); + if (empty($options['login'])) { + return true; + } + /* Fetch the user's last login time. */ $old_login = @unserialize($GLOBALS['prefs']->getValue('last_login'));