From dd2216fff583f53621f057c8be6c21e7fe55271d Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 19 May 2010 14:57:57 +0100 Subject: [PATCH] Fix checking for expired sessions. --- framework/Auth/lib/Horde/Auth/Shibboleth.php | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/framework/Auth/lib/Horde/Auth/Shibboleth.php b/framework/Auth/lib/Horde/Auth/Shibboleth.php index 01311e714..7b0e2b73d 100644 --- a/framework/Auth/lib/Horde/Auth/Shibboleth.php +++ b/framework/Auth/lib/Horde/Auth/Shibboleth.php @@ -83,7 +83,7 @@ class Horde_Auth_Shibboleth extends Horde_Auth_Base public function checkExistingAuth() { return !empty($_SERVER[$this->_params['username_header']]) && - $_SERVER[$this->_params['username_header']] == Horde_Auth::getAuth(); + $this->_removeScope($_SERVER[$this->_params['username_header']]) == Horde_Auth::getAuth(); } /** @@ -101,12 +101,7 @@ class Horde_Auth_Shibboleth extends Horde_Auth_Base $username = $_SERVER[$this->_params['username_header']]; // Remove scope from username, if present. - $pos = strrpos($username, '@'); - if ($pos !== false) { - $username = substr($username, 0, $pos); - } - - $this->_credentials['userId'] = $username; + $this->_credentials['userId'] = $this->_removeScope($username); // Set password for hordeauth login. switch ($this->_params['password_holder']) { @@ -125,4 +120,20 @@ class Horde_Auth_Shibboleth extends Horde_Auth_Base return true; } + /** + * Removes the scope from the user name, if present. + * + * @param string $username The full user name. + * + * @return string The user name without scope. + */ + protected function _removeScope($username) + { + $pos = strrpos($username, '@'); + if ($pos !== false) { + $username = substr($username, 0, $pos); + } + return $username; + } + } -- 2.11.0