Remove use of global registry in Auth
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 7 Jun 2010 23:23:25 +0000 (17:23 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 8 Jun 2010 17:54:59 +0000 (11:54 -0600)
framework/Auth/lib/Horde/Auth/Base.php
framework/Auth/lib/Horde/Auth/Customsql.php
framework/Auth/lib/Horde/Auth/Shibboleth.php
framework/Core/lib/Horde/Core/Factory/Auth.php

index ba6c544..c339ceb 100644 (file)
@@ -70,6 +70,7 @@ abstract class Horde_Auth_Base
      *
      * @param array $params  Optional parameters:
      * <pre>
+     * '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()
index 26920b8..6d85006 100644 (file)
@@ -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']
         );
 
index 4a0ca6c..7b610d9 100644 (file)
@@ -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']);
     }
 
     /**
index bb03a27..ac859c3 100644 (file)
@@ -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');