]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-8590 auth cleanup - part 6
authorskodak <skodak>
Wed, 21 Feb 2007 21:42:10 +0000 (21:42 +0000)
committerskodak <skodak>
Wed, 21 Feb 2007 21:42:10 +0000 (21:42 +0000)
14 files changed:
auth/cas/auth.php
auth/db/auth.php
auth/email/auth.php
auth/imap/auth.php
auth/ldap/auth.php
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

index af55197908fb7e4c221eae20d3cf11b6b1c99f24..61ac669ceae7b857e5a73d96bc03a0f2ca566f6e 100644 (file)
@@ -219,7 +219,7 @@ class auth_plugin_cas {
      * @return bool
      */
     function can_change_password() {
-        return false;
+        return !empty($this->config->changepasswordurl);
     }
 
     /**
@@ -235,10 +235,10 @@ class auth_plugin_cas {
     }
 
     /**
-     * Returns the URL for changing the user's pw, or false if the default can
+     * Returns the URL for changing the user's pw, or empty if the default can
      * be used.
      *
-     * @return bool
+     * @return string
      */
     function change_password_url() {
         return $this->config->changepasswordurl;
index 27f0574187e4f6f68573dc03a01be2213d3fdcbb..a13744b149c85d15729be33ff84009314c1a9366 100644 (file)
@@ -591,17 +591,23 @@ class auth_plugin_db {
      * @return bool
      */
     function can_change_password() {
-        return ($this->config->passtype === 'internal');
+        return ($this->config->passtype == 'internal' or !empty($this->config->changepasswordurl));
     }
 
     /**
-     * Returns the URL for changing the user's pw, or false if the default can
+     * Returns the URL for changing the user's pw, or empty if the default can
      * be used.
      *
-     * @return bool
+     * @return string
      */
     function change_password_url() {
-        return $this->config->changepasswordurl;
+        if ($this->config->passtype == 'internal') {
+            // standard form
+            return '';
+        } else {
+            // use custom url
+            return $this->config->changepasswordurl;
+        }
     }
 
     /**
index 140fc2195b120789e92eb978d8ef311242396ab7..6c2191a62b9117aa1c3968a68070d50ffe3d3d90 100644 (file)
@@ -74,7 +74,7 @@ class auth_plugin_email {
         return update_internal_user_password($user, $newpassword);
     }
 
-    /*
+    /**
      * Sign up a new user ready for confirmation.
      */
     function user_signup($user, $notify = true) {
@@ -93,7 +93,7 @@ class auth_plugin_email {
         }
     }
 
-    /*
+    /**
      * Confirm the new user as registered.
      */
     function user_confirm($username, $confirmsecret) {
@@ -135,13 +135,22 @@ class auth_plugin_email {
     }
 
     /**
-     * Returns the URL for changing the user's pw, or false if the default can
+     * Returns the URL for changing the user's pw, or empty if the default can
      * be used.
      *
-     * @return bool
+     * @return mixed
      */
     function change_password_url() {
-        return false;
+        return ''; // use dafult internal method
+    }
+
+    /**
+     * Returns true if plugin allows resetting of internal password.
+     *
+     * @return bool
+     */
+    function can_reset_password() {
+        return true;
     }
 
     /**
index 448c3ad13f6e86aec8e673616e13c35490fcac99..3c1c0f7e2253d3835eacd431b8a5132ad3897018 100644 (file)
@@ -37,8 +37,8 @@ class auth_plugin_imap {
      * Returns true if the username and password work and false if they are
      * wrong or don't exist.
      *
-     * @param string $username The username
-     * @param string $password The password
+     * @param string $username The username (with system magic quotes)
+     * @param string $password The password (with system magic quotes)
      * @return bool Authentication success or failure.
      */
     function user_login ($username, $password) {
@@ -71,7 +71,7 @@ class auth_plugin_imap {
             }
 
             error_reporting(0);
-            $connection = imap_open($host, $username, $password, OP_HALFOPEN);
+            $connection = imap_open($host, stripslashes($username), stripslashes($password), OP_HALFOPEN);
             error_reporting($CFG->debug);
 
             if ($connection) {
@@ -99,18 +99,17 @@ class auth_plugin_imap {
      * @return bool
      */
     function can_change_password() {
-        return false;
+        return !empty($this->config->changepasswordurl);
     }
 
     /**
-     * Returns the URL for changing the user's pw, or false if the default can
+     * Returns the URL for changing the user's pw, or empty if the default can
      * be used.
      *
-     * @return bool
+     * @return string
      */
     function change_password_url() {
-        return $CFG->changepasswordurl; // TODO: will this be global?
-        //return $this->config->changepasswordurl;
+        return $this->config->changepasswordurl;
     }
 
     /**
index daf3c7ce06620aba5afa8692d0f80b59fad18549..96d932705234ccd717cf7fe86d0d4906ed2943ba 100644 (file)
@@ -48,9 +48,12 @@ class auth_plugin_ldap {
             }
         }
         //hack prefix to objectclass
-        if ('objectClass=' != substr($this->config->objectclass, 0, 12)) {
-           $this->config->objectclass = 'objectClass='.$this->config->objectclass;
+        if (empty($this->config->objectclass)) {        // Can't send empty filter
+            $this->config->objectclass='objectClass=*';
+        } else if (strpos($this->config->objectclass, 'objectClass=') !== 0) {
+            $this->config->objectclass = 'objectClass='.$this->config->objectclass;
         }
+
     }
 
     /**
@@ -135,10 +138,6 @@ class auth_plugin_ldap {
 
         $user_dn = $this->ldap_find_userdn($ldapconnection, $extusername);
 
-        if (empty($this->config->objectclass)) {        // Can't send empty filter
-            $this->config->objectclass="objectClass=*";
-        }
-
         if (!$user_info_result = ldap_read($ldapconnection, $user_dn, $this->config->objectclass, $search_attribs)) {
             return false; // error!
         }
@@ -387,10 +386,6 @@ class auth_plugin_ldap {
         //// get user's list from ldap to sql in a scalable fashion
         ////
         // prepare some data we'll need
-        if (! empty($this->config->objectclass)) {
-            $this->config->objectclass="objectClass=*";
-        }
-
         $filter = "(&(".$this->config->user_attribute."=*)(".$this->config->objectclass."))";
 
         $contexts = explode(";",$this->config->contexts);
@@ -1500,11 +1495,11 @@ class auth_plugin_ldap {
      * @return bool
      */
     function can_change_password() {
-        return true;
+        return !empty($this->config->stdchangepassword) or !empty($this->config->changepasswordurl);
     }
 
     /**
-     * Returns the URL for changing the user's pw, or false if the default can
+     * Returns the URL for changing the user's pw, or empty if the default can
      * be used.
      *
      * @return string url
@@ -1513,7 +1508,7 @@ class auth_plugin_ldap {
         if (empty($this->config->stdchangepassword)) {
             return $this->config->changepasswordurl;
         } else {
-            return false;
+            return '';
         }
     }
 
index cd867f4003397f615afdf52077e2cf51f754647e..d8bd41fe3f225d204f974b59e5b41c3a9f22559d 100644 (file)
@@ -87,13 +87,22 @@ class auth_plugin_manual
     }
 
     /**
-     * Returns the URL for changing the user's pw, or false if the default can
+     * Returns the URL for changing the user's pw, or empty if the default can
      * be used.
      *
-     * @return bool
+     * @return string
      */
     function change_password_url() {
-        return false;
+        return '';
+    }
+
+    /**
+     * Returns true if plugin allows resetting of internal password.
+     *
+     * @return bool
+     */
+    function can_reset_password() {
+        return true;
     }
 
     /**
index 2d672b8dde4d3942930596e20f84c15201b1adbb..9c8c07a394fb90bbf651a7ffffe9ded1c183c6bd 100644 (file)
@@ -609,6 +609,7 @@ class auth_plugin_mnet
      * @return bool
      */
     function can_change_password() {
+        //TODO: it should be able to redirect, right?
         return false;
     }
 
@@ -616,10 +617,10 @@ class auth_plugin_mnet
      * Returns the URL for changing the user's pw, or false if the default can
      * be used.
      *
-     * @return bool
+     * @return string
      */
     function change_password_url() {
-        return false;
+        return '';
     }
 
     /**
index 1cb5d376fc6d0fa062cf31c58a0a0c77b3f4a0a9..9e236ee68d3793fd854b3ad3a05a4b5360efc8bf 100644 (file)
@@ -37,8 +37,8 @@ class auth_plugin_nntp {
      * Returns true if the username and password work and false if they are
      * wrong or don't exist.
      *
-     * @param string $username The username
-     * @param string $password The password
+     * @param string $username The username (with system magic quotes)
+     * @param string $password The password (with system magic quotes)
      * @return bool Authentication success or failure.
      */
     function user_login ($username, $password) {
@@ -55,7 +55,7 @@ class auth_plugin_nntp {
             $host = '{' . trim($host) . ':' . $this->config->port . '/nntp}';
 
             error_reporting(0);
-            $connection = imap_open($host, $username, $password, OP_HALFOPEN);
+            $connection = imap_open($host, stripslashes($username), stripslashes($password), OP_HALFOPEN);
             error_reporting($CFG->debug);
 
             if ($connection) {
index 1ff8341094b936fdbc06185436f40e40af6cc654..baf920622826bee437028785c805871b051bf5c7 100644 (file)
@@ -63,16 +63,6 @@ class auth_plugin_nologin {
         return false;
     }
 
-    /**
-     * Returns the URL for changing the user's pw, or false if the default can
-     * be used.
-     *
-     * @return bool
-     */
-    function change_password_url() {
-        return false;
-    }
-
     /**
      * Prints a form for configuring this authentication plugin.
      *
index 57c2b2a2f460423e24e43ecb393bb4475680036c..f7b8f0a9cbfd5c2e82e46a12d2f48f1238a69349 100644 (file)
@@ -87,13 +87,22 @@ class auth_plugin_none {
     }
 
     /**
-     * Returns the URL for changing the user's pw, or false if the default can
+     * Returns the URL for changing the user's pw, or empty if the default can
      * be used.
      *
-     * @return bool
+     * @return string
      */
     function change_password_url() {
-        return false;
+        return '';
+    }
+
+    /**
+     * Returns true if plugin allows resetting of internal password.
+     *
+     * @return bool
+     */
+    function can_reset_password() {
+        return true;
     }
 
     /**
index 45ac727b1cde38ec4f95d172433f470b92758832..28d3c75034b19d7102f0ada1fe2e3ecba1e51ab3 100644 (file)
@@ -57,8 +57,8 @@ class auth_plugin_pam {
      * Returns true if the username and password work and false if they are
      * wrong or don't exist.
      *
-     * @param string $username The username
-     * @param string $password The password
+     * @param string $username The username (with system magic quotes)
+     * @param string $password The password (with system magic quotes)
      * @return bool Authentication success or failure.
      */
     function user_login ($username, $password) {
@@ -70,7 +70,7 @@ class auth_plugin_pam {
 
         // call_time_pass_reference of errormessage is deprecated - throws warnings in multiauth
         //if (pam_auth($username, $password, &$errormessage)) {
-        if (pam_auth($username, $password)) {
+        if (pam_auth(stripslashes($username), strislashes($password))) {
             return true;
         }
         else {
index 7927b06c069cc178e4ca7fe7769f028a499b4976..431d20796a1ed2d053e874fa22ed6ac84ffff1f2 100644 (file)
@@ -37,8 +37,8 @@ class auth_plugin_pop3 {
      * Returns true if the username and password work and false if they are
      * wrong or don't exist.
      *
-     * @param string $username The username
-     * @param string $password The password
+     * @param string $username The username (with system magic quotes)
+     * @param string $password The password (with system magic quotes)
      * @return bool Authentication success or failure.
      */
     function user_login($username, $password) {
@@ -72,7 +72,7 @@ class auth_plugin_pop3 {
             }
 
             error_reporting(0);
-            $connection = imap_open($host, $username, $password);
+            $connection = imap_open($host, stripslashes($username), stripslashes($password));
             error_reporting($CFG->debug);
 
             if ($connection) {
@@ -99,7 +99,7 @@ class auth_plugin_pop3 {
      * @return bool
      */
     function can_change_password() {
-        return false;
+        return !empty($this->config->changepasswordurl);
     }
 
     /**
@@ -109,8 +109,7 @@ class auth_plugin_pop3 {
      * @return bool
      */
     function change_password_url() {
-        return $CFG->changepasswordurl; // TODO: will this be global?
-        //return $this->config->changepasswordurl;
+        return $this->config->changepasswordurl;
     }
 
     /**
index 1f30f0f1b4f80c34e6ce71dcfe11c516cd3f65ca..7f1776aeafb40ed7009d3e7dc0aabcb8fa7b343e 100644 (file)
@@ -38,8 +38,8 @@ class auth_plugin_radius {
      * Returns true if the username and password work and false if they are
      * wrong or don't exist.
      *
-     * @param string $username The username
-     * @param string $password The password
+     * @param string $username The username (with system magic quotes)
+     * @param string $password The password (with system magic quotes)
      * @return bool Authentication success or failure.
      */
     function user_login ($username, $password) {
@@ -52,7 +52,7 @@ class auth_plugin_radius {
         // printf("nasport: $this->config->nasport <br/>");
         // printf("secret: $this->config->secret <br/>");
 
-        $rauth = new Auth_RADIUS_PAP($username, $password);
+        $rauth = new Auth_RADIUS_PAP(stripslashes($username), stripslashes($password));
         $rauth->addServer($this->config->host, $this->config->nasport, $this->config->secret);
 
         if (!$rauth->start()) {
index 7450f7a828bd8b67a1d169ff6f9e260b55de909f..eb759428dee9801e5d171d8c6ef63ff81188f9ee 100644 (file)
@@ -43,8 +43,8 @@ class auth_plugin_shibboleth {
      * Returns true if the username and password work and false if they are
      * wrong or don't exist.
      *
-     * @param string $username The username
-     * @param string $password The password
+     * @param string $username The username (with system magic quotes)
+     * @param string $password The password (with system magic quotes)
      * @return bool Authentication success or failure.
      */
     function user_login($username, $password) {
@@ -78,11 +78,7 @@ class auth_plugin_shibboleth {
         $search_attribs = array();
 
         foreach ($attrmap as $key=>$value) {
-            if (!empty($CFG->unicodedb)) {
-                $result[$key] = $this->get_first_string($_SERVER[$value]);
-            } else {
-                $result[$key] = $this->get_first_string(utf8_decode($_SERVER[$value]));
-            }
+            $result[$key] = $this->get_first_string($_SERVER[$value]);
         }
 
          // Provide an API to modify the information to fit the Moodle internal