From 302edad7eea3d0031536ea672ca11f2f598b8a4d Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 7 Jun 2010 17:23:25 -0600 Subject: [PATCH] Remove use of global registry in Auth --- framework/Auth/lib/Horde/Auth/Base.php | 10 ++++++++-- framework/Auth/lib/Horde/Auth/Customsql.php | 2 +- framework/Auth/lib/Horde/Auth/Shibboleth.php | 2 +- framework/Core/lib/Horde/Core/Factory/Auth.php | 1 + 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/framework/Auth/lib/Horde/Auth/Base.php b/framework/Auth/lib/Horde/Auth/Base.php index ba6c544d1..c339cebdf 100644 --- a/framework/Auth/lib/Horde/Auth/Base.php +++ b/framework/Auth/lib/Horde/Auth/Base.php @@ -70,6 +70,7 @@ abstract class Horde_Auth_Base * * @param array $params Optional parameters: *
+     * 'default_user' - (string) The default user.
      * 'logger' - (Horde_Log_Logger) A logger object.
      * 'notify_expire' - (callback) Callback function to output notification
      *                   when password is about to expire. Passed one
@@ -83,6 +84,10 @@ abstract class Horde_Auth_Base
             unset($params['logger']);
         }
 
+        $params = array_merge(array(
+            'default_user' => ''
+        ), $params);
+
         $this->_params = $params;
     }
 
@@ -232,13 +237,14 @@ abstract class Horde_Auth_Base
     /**
      * Automatic authentication.
      *
-     * @return boolean  Whether or not the user is authenticated automatically.
+     * @return boolean  Whether or not the user is authenticated
+     *                  automatically.
      * @throws Horde_Auth_Exception
      */
     public function transparent()
     {
         $userId = empty($this->_credentials['userId'])
-            ? $GLOBALS['registry']->getAuth()
+            ? $this->_params['default_user']
             : $this->_credentials['userId'];
         $credentials = empty($this->_credentials['credentials'])
             ? Horde_Auth::getCredential()
diff --git a/framework/Auth/lib/Horde/Auth/Customsql.php b/framework/Auth/lib/Horde/Auth/Customsql.php
index 26920b8b2..6d85006ad 100644
--- a/framework/Auth/lib/Horde/Auth/Customsql.php
+++ b/framework/Auth/lib/Horde/Auth/Customsql.php
@@ -228,7 +228,7 @@ class Horde_Auth_Customsql extends Horde_Auth_Sql
         /* Build a custom query, based on the config file. */
         $query = str_replace(
             '\L',
-            $this->_db->quote($GLOBALS['registry']->getAuth()),
+            $this->_db->quote($this->_params['default_user']),
             $this->_params['query_list']
         );
 
diff --git a/framework/Auth/lib/Horde/Auth/Shibboleth.php b/framework/Auth/lib/Horde/Auth/Shibboleth.php
index 4a0ca6c46..7b610d9cd 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']]) &&
-            $this->_removeScope($_SERVER[$this->_params['username_header']]) == $GLOBALS['registry']->getAuth();
+               ($this->_removeScope($_SERVER[$this->_params['username_header']]) == $this->_params['default_user']);
     }
 
     /**
diff --git a/framework/Core/lib/Horde/Core/Factory/Auth.php b/framework/Core/lib/Horde/Core/Factory/Auth.php
index bb03a275e..ac859c367 100644
--- a/framework/Core/lib/Horde/Core/Factory/Auth.php
+++ b/framework/Core/lib/Horde/Core/Factory/Auth.php
@@ -135,6 +135,7 @@ class Horde_Core_Factory_Auth
                 break;
             }
 
+            $params['default_user'] = $GLOBALS['registry']->getAuth();
             $params['logger'] = $this->_injector->getInstance('Horde_Log_Logger');
             $params['notify_expire'] = array($this, 'notifyExpire');
 
-- 
2.11.0