]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-20934 'not cached' flag used in all auth plugins that do not need the password
authorPetr Skoda <skodak@moodle.org>
Mon, 23 Nov 2009 21:50:40 +0000 (21:50 +0000)
committerPetr Skoda <skodak@moodle.org>
Mon, 23 Nov 2009 21:50:40 +0000 (21:50 +0000)
19 files changed:
auth/cas/auth.php
auth/db/auth.php
auth/email/auth.php
auth/fc/auth.php
auth/imap/auth.php
auth/ldap/auth.php
auth/ldap/config.html
auth/manual/auth.php
auth/mnet/auth.php
auth/nntp/auth.php
auth/nologin/auth.php
auth/none/auth.php
auth/pam/auth.php
auth/pop3/auth.php
auth/radius/auth.php
auth/shibboleth/auth.php
backup/restorelib.php
lib/authlib.php
lib/moodlelib.php

index 2e65812baf7536d67af077514eb4b13e47e6e8c2..703cebd68f3c8ef7923268cf92a615a4d4181263 100644 (file)
@@ -48,6 +48,11 @@ class auth_plugin_cas extends auth_plugin_base {
             $this->config->objectclass = 'objectClass='.$this->config->objectclass;
         }
     }
+
+    function prevent_local_passwords() {
+        return true;
+    }
+
     /**
      * Authenticates user againt CAS
      * Returns true if the username and password work and false if they are
index 724496cef9d0fe3a6ba931e2b9ac7129446b5892..caf57f0c4cfb3798caa18b9d04cecc0c7b6df745 100644 (file)
@@ -563,6 +563,13 @@ class auth_plugin_db extends auth_plugin_base {
         }
     }
 
+    function prevent_local_passwords() {
+        if (!isset($this->config->passtype)) {
+            return false;
+        }
+        return ($this->config->passtype != 'internal');
+    }
+
     /**
      * Returns true if this authentication plugin is 'internal'.
      *
index 5b709d2cc89bb666498277d7fe32c149be6fdb7f..a1bb6e4ee8c45accc7ee0af9828a95a1794b27e4 100644 (file)
@@ -146,6 +146,10 @@ class auth_plugin_email extends auth_plugin_base {
         }
     }
 
+    function prevent_local_passwords() {
+        return false;
+    }
+
     /**
      * Returns true if this authentication plugin is 'internal'.
      *
index 51035232e1f2d4acd4629a05bbae7e7a84555196..8e9018204a95ef7134ecd5c571aa631c140ba4fc 100644 (file)
@@ -144,6 +144,10 @@ class auth_plugin_fc extends auth_plugin_base {
         return false;
     }
 
+    function prevent_local_passwords() {
+        return true;
+    }
+
     /**
      * Returns true if this authentication plugin is 'internal'.
      *
index e8028c3054d4a887bd159cb037299950d3bb37a1..9bf042d60fbbd179e3ea1b029e9236b4128dc6ac 100644 (file)
@@ -81,6 +81,10 @@ class auth_plugin_imap extends auth_plugin_base {
         return false;  // No match
     }
 
+    function prevent_local_passwords() {
+        return true;
+    }
+
     /**
      * Returns true if this authentication plugin is 'internal'.
      *
index ca3a7746d5ce31675f25057b13a191f44b6e491c..9162ab642183045eadb9527e45edac6aabf83122 100644 (file)
@@ -1749,6 +1749,10 @@ class auth_plugin_ldap extends auth_plugin_base {
         return ($fresult);
     }
 
+    function prevent_local_passwords() {
+        return !empty($this->config->preventpassindb);
+    }
+
     /**
      * Returns true if this authentication plugin is 'internal'.
      *
index d00f7dd012d4170d0f386ef6342f63170cc3717e..51f26b878a48598f07632dfaed26254e5742b185 100644 (file)
@@ -16,7 +16,7 @@
     if (!isset($config->opt_deref))
         { $config->opt_deref = LDAP_DEREF_NEVER; }
     if (!isset($config->preventpassindb))
-        { $config->preventpassindb = 0; }
+        { $config->preventpassindb = 1; }
     if (!isset($config->bind_dn))
         {$config->bind_dn = ''; }
     if (!isset($config->bind_pw))
index 4010c8f9b620e9b6b205a23f084c62e3286db150..31a643ad22c0491cb469834b45bf102370c24771 100644 (file)
@@ -62,6 +62,10 @@ class auth_plugin_manual extends auth_plugin_base {
         return update_internal_user_password($user, $newpassword);
     }
 
+    function prevent_local_passwords() {
+        return false;
+    }
+
     /**
      * Returns true if this authentication plugin is 'internal'.
      *
index ddae159e146a9f70f5fe02128e9adc614abb0b89..5da68394cd35dfe35c787b82ef62df6c9d7fa9c3 100644 (file)
@@ -578,6 +578,10 @@ class auth_plugin_mnet extends auth_plugin_base {
         $DB->delete_records_select('mnet_enrol_assignments', $whereclause, array($userid, $MNET_REMOTE_CLIENT->id));
     }
 
+    function prevent_local_passwords() {
+        return true;
+    }
+
     /**
      * Returns true if this authentication plugin is 'internal'.
      *
index 36cdeb395ca4e4ba675dd49d256868c5a78ca5eb..de0aa4ee1a3273833d6d068b6f3f65c3eb18b811 100644 (file)
@@ -64,6 +64,10 @@ class auth_plugin_nntp extends auth_plugin_base {
         return false;
     }
 
+    function prevent_local_passwords() {
+        return true;
+    }
+
     /**
      * Returns true if this authentication plugin is 'internal'.
      *
index 20794da7194004ee86011b3e51ed62f877a71104..72f5fa85753d402dcadc38772fa13841441a951c 100644 (file)
@@ -46,6 +46,11 @@ class auth_plugin_nologin extends auth_plugin_base {
         return false;
     }
 
+    function prevent_local_passwords() {
+        // just in case, we do not want to loose the passwords
+        return false;
+    }
+
     /**
      * No external data sync.
      *
index e6022cdc38780f3ad6250583d7b56aea9a51e780..9a1cbf9ac04f50deda815669ad6ab838e9de513f 100644 (file)
@@ -62,6 +62,10 @@ class auth_plugin_none extends auth_plugin_base {
         return update_internal_user_password($user, $newpassword);
     }
 
+    function prevent_local_passwords() {
+        return false;
+    }
+
     /**
      * Returns true if this authentication plugin is 'internal'.
      *
index 5bb65831a61e2ac1509ab743985eb399432fc78e..c0afbe0ed8153709d1af590ee1751b7b6c0704b5 100644 (file)
@@ -77,6 +77,10 @@ class auth_plugin_pam extends auth_plugin_base {
         }
     }
 
+    function prevent_local_passwords() {
+        return true;
+    }
+
     /**
      * Returns true if this authentication plugin is 'internal'.
      *
index d4abd780e126a28b8122f9968e8fe0497f5ae8e6..a49f510359adf93c79625d9a7cfd3334d2cab2f2 100644 (file)
@@ -81,6 +81,10 @@ class auth_plugin_pop3 extends auth_plugin_base {
         return false;  // No matches found
     }
 
+    function prevent_local_passwords() {
+        return true;
+    }
+
     /**
      * Returns true if this authentication plugin is 'internal'.
      *
index 976432d968009d82e6d529cd8691740bf81b3799..e6eb6a5a1fc5282a2d2cf98851f8962f3bdbdecd 100644 (file)
@@ -126,6 +126,10 @@ class auth_plugin_radius extends auth_plugin_base {
         $rauth->close();
     }
 
+    function prevent_local_passwords() {
+        return true;
+    }
+
     /**
      * Returns true if this authentication plugin is 'internal'.
      *
index 1cfaa462bca351eec995343dd81b0792252e1ecd..3e557ed3605543a55472039706b0a8ecdf3c0e95 100644 (file)
@@ -152,6 +152,10 @@ class auth_plugin_shibboleth extends auth_plugin_base {
         return $moodleattributes;
     }
 
+    function prevent_local_passwords() {
+        return true;
+    }
+
     /**
      * Returns true if this authentication plugin is 'internal'.
      *
index eccc2fab4abc817eef3e96b6a65bd45826489242..42b0ce500d2eabbff2d08e6d1c74d462e5a44273 100644 (file)
@@ -2707,7 +2707,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3);
                         if (!array_key_exists($user->auth, $authcache)) { // Not in cache
                             $userauth = new stdClass();
                             $authplugin = get_auth_plugin($user->auth);
-                            $userauth->preventpassindb = !empty($authplugin->config->preventpassindb);
+                            $userauth->preventpassindb = $authplugin->prevent_local_passwords();
                             $userauth->isinternal      = $authplugin->is_internal();
                             $userauth->canresetpwd     = $authplugin->can_reset_password();
                             $authcache[$user->auth] = $userauth;
@@ -2715,7 +2715,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3);
                             $userauth = $authcache[$user->auth]; // Get from cache
                         }
 
-                        // Respect strange config in some (ldap) plugins. Isn't this a dupe of is_internal() ?
+                        // Most external plugins do not store passwords locally
                         if (!empty($userauth->preventpassindb)) {
                             $user->password = 'not cached';
 
index b89aa0160f3357705fcfc4862b72cf64002248b2..eaffbf4bc0b8239d7991b49ba28e6215a4402a33 100644 (file)
@@ -155,6 +155,15 @@ class auth_plugin_base {
         return true;
     }
 
+    /**
+     * Indicates if password hashes should be stored in local moodle database.
+     * @return bool true means md5 password hash stored in user table, false means flag 'not_cached' stored there instead
+     */
+    function prevent_local_passwords() {
+        // NOTE: this will be changed to true in 2.0
+        return false;
+    }
+
     /**
      * Updates the user's password.
      *
index 2e2ada81e644b78c91c6aa494dd1050785795615..8ecf1953ede0c1193a3511656e3a39e65c977b59 100644 (file)
@@ -3715,7 +3715,7 @@ function update_internal_user_password(&$user, $password) {
     global $CFG, $DB;
 
     $authplugin = get_auth_plugin($user->auth);
-    if (!empty($authplugin->config->preventpassindb)) {
+    if ($authplugin->prevent_local_passwords()) {
         $hashedpassword = 'not cached';
     } else {
         $hashedpassword = hash_internal_user_password($password);