diff --git a/auth/radius/auth.php b/auth/radius/auth.php deleted file mode 100644 index 24ae5d39005..00000000000 --- a/auth/radius/auth.php +++ /dev/null @@ -1,218 +0,0 @@ -. - -/** - * Authentication Plugin: RADIUS Authentication - * - * Authenticates against a RADIUS server. - * Contributed by Clive Gould - * CHAP support contributed by Stanislav Tsymbalov http://www.tsymbalov.net/ - * - * @package auth_radius - * @author Martin Dougiamas - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License - */ - -defined('MOODLE_INTERNAL') || die(); - -require_once($CFG->libdir.'/authlib.php'); - -/** - * RADIUS authentication plugin. - */ -class auth_plugin_radius extends auth_plugin_base { - - /** - * Constructor. - */ - public function __construct() { - $this->authtype = 'radius'; - $this->config = get_config('auth/radius'); - } - - /** - * Old syntax of class constructor. Deprecated in PHP7. - * - * @deprecated since Moodle 3.1 - */ - public function auth_plugin_radius() { - debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); - self::__construct(); - } - - /** - * 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 - * @return bool Authentication success or failure. - */ - function user_login ($username, $password) { - require_once 'Auth/RADIUS.php'; - require_once 'Crypt/CHAP.php'; - - // Added by Clive on 7th May for test purposes - // printf("Username: $username
"); - // printf("Password: $password
"); - // printf("host: $this->config->host
"); - // printf("nasport: $this->config->nasport
"); - // printf("secret: $this->config->secret
"); - - // Added by Stanislav Tsymbalov on 12th March 2008 only for test purposes - //$type = 'PAP'; - //$type = 'CHAP_MD5'; - //$type = 'MSCHAPv1'; - //$type = 'MSCHAPv2'; - $type = $this->config->radiustype; - if (empty($type)) { - $type = 'PAP'; - } - - $classname = 'Auth_RADIUS_' . $type; - $rauth = new $classname($username, $password); - $rauth->addServer($this->config->host, $this->config->nasport, $this->config->secret); - - $rauth->username = $username; - - switch($type) { - case 'CHAP_MD5': - case 'MSCHAPv1': - $classname = $type == 'MSCHAPv1' ? 'Crypt_CHAP_MSv1' : 'Crypt_CHAP_MD5'; - $crpt = new $classname; - $crpt->password = $password; - $rauth->challenge = $crpt->challenge; - $rauth->chapid = $crpt->chapid; - $rauth->response = $crpt->challengeResponse(); - $rauth->flags = 1; - // If you must use deprecated and weak LAN-Manager-Responses use this: - // $rauth->lmResponse = $crpt->lmChallengeResponse(); - // $rauth->flags = 0; - break; - - case 'MSCHAPv2': - $crpt = new Crypt_CHAP_MSv2; - $crpt->username = $username; - $crpt->password = $password; - $rauth->challenge = $crpt->authChallenge; - $rauth->peerChallenge = $crpt->peerChallenge; - $rauth->chapid = $crpt->chapid; - $rauth->response = $crpt->challengeResponse(); - break; - - default: - $rauth->password = $password; - break; - } - - if (!$rauth->start()) { - printf("Radius start: %s
\n", $rauth->getError()); - exit; - } - - $result = $rauth->send(); - if ($rauth->isError($result)) { - printf("Radius send failed: %s
\n", $result->getMessage()); - exit; - } else if ($result === true) { - // printf("Radius Auth succeeded
\n"); - return true; - } else { - // printf("Radius Auth rejected
\n"); - return false; - } - - // get attributes, even if auth failed - if (!$rauth->getAttributes()) { - printf("Radius getAttributes: %s
\n", $rauth->getError()); - } else { - $rauth->dumpAttributes(); - } - - $rauth->close(); - } - - function prevent_local_passwords() { - return true; - } - - /** - * Returns true if this authentication plugin is 'internal'. - * - * @return bool - */ - function is_internal() { - return false; - } - - /** - * Returns true if this authentication plugin can change the user's - * password. - * - * @return bool - */ - function can_change_password() { - return false; - } - - /** - * Prints a form for configuring this authentication plugin. - * - * This function is called from admin/auth.php, and outputs a full page with - * a form for configuring this plugin. - * - * @param array $page An object containing all the data for this page. - */ - function config_form($config, $err, $user_fields) { - global $OUTPUT; - - include "config.html"; - } - - /** - * Processes and stores configuration data for this authentication plugin. - */ - function process_config($config) { - // set to defaults if undefined - if (!isset ($config->host)) { - $config->host = '127.0.0.1'; - } - if (!isset ($config->nasport)) { - $config->nasport = '1812'; - } - if (!isset($config->radiustype)) { - $config->radiustype = 'PAP'; - } - if (!isset ($config->secret)) { - $config->secret = ''; - } - if (!isset($config->changepasswordurl)) { - $config->changepasswordurl = ''; - } - - // save settings - set_config('host', $config->host, 'auth/radius'); - set_config('nasport', $config->nasport, 'auth/radius'); - set_config('secret', $config->secret, 'auth/radius'); - set_config('changepasswordurl', $config->changepasswordurl, 'auth/radius'); - set_config('radiustype', $config->radiustype, 'auth/radius'); - - return true; - } - -} - - diff --git a/auth/radius/config.html b/auth/radius/config.html deleted file mode 100644 index 3ae3f2621c7..00000000000 --- a/auth/radius/config.html +++ /dev/null @@ -1,114 +0,0 @@ -

Warning: The PHP RADIUS extension is not present. Please ensure it is installed and enabled.

'; -} -include_once 'Auth/RADIUS.php'; -if (!class_exists('Auth_RADIUS')) { - print '

Warning: There is a problem with the PHP Pear Auth_RADIUS package. Please ensure it is installed correctly.

'; -} - -// set to defaults if undefined -if (!isset($config->host)) { - $config->host = '127.0.0.1'; -} -if (!isset($config->nasport)) { - $config->nasport = '1812'; -} -if (!isset($config->radiustype)) { - $config->radiustype = 'PAP'; -} -if (!isset($config->secret)) { - $config->secret = ''; -} -if (!isset($config->changepasswordurl)) { - $config->changepasswordurl = ''; -} - -?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - error_text($err['host']); - } - - ?> -
- - error_text($err['nasport']); - } - - ?> -
-radiustype, false); - - if (isset($err['radiustype'])) { - echo $OUTPUT->error_text($err['radiustype']); - } - -?> -
- - error_text($err['secret']); - } - - ?> -
- - error_text($err['changepasswordurl']); - } - - ?> -
diff --git a/auth/radius/db/install.php b/auth/radius/db/install.php deleted file mode 100644 index 9423db7ea39..00000000000 --- a/auth/radius/db/install.php +++ /dev/null @@ -1,6 +0,0 @@ -. - -/** - * Strings for component 'auth_radius', language 'en'. - * - * @package auth_radius - * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -$string['auth_radiusdescription'] = 'This method uses a RADIUS server to check whether a given username and password is valid.'; -$string['auth_radiushost'] = 'Address of the RADIUS server'; -$string['auth_radiushost_key'] = 'Host'; -$string['auth_radiuschangepasswordurl_key'] = 'Password-change URL'; -$string['auth_radiusnasport'] = 'Port to use to connect'; -$string['auth_radiusnasport_key'] = 'Port'; -$string['auth_radiussecret'] = 'Shared secret'; -$string['auth_radiussecret_key'] = 'Secret'; -$string['auth_radiustype'] = 'Choose an authentication scheme to use with the RADIUS server.'; -$string['auth_radiustypechapmd5'] = 'CHAP MD5'; -$string['auth_radiustype_key'] = 'Authentication'; -$string['auth_radiustypemschapv1'] = 'Microsoft CHAP version 1'; -$string['auth_radiustypemschapv2'] = 'Microsoft CHAP version 2'; -$string['auth_radiustypepap'] = 'PAP'; -$string['pluginname'] = 'RADIUS server'; diff --git a/auth/radius/version.php b/auth/radius/version.php deleted file mode 100644 index 72b1e71a7cb..00000000000 --- a/auth/radius/version.php +++ /dev/null @@ -1,29 +0,0 @@ -. - -/** - * Version information - * - * @package auth_radius - * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -$plugin->version = 2016052300; // The current plugin version (Date: YYYYMMDDXX) -$plugin->requires = 2016051900; // Requires this Moodle version -$plugin->component = 'auth_radius'; // Full name of the plugin (used for diagnostics) diff --git a/auth/upgrade.txt b/auth/upgrade.txt index 54f60e733c2..e181b35b54c 100644 --- a/auth/upgrade.txt +++ b/auth/upgrade.txt @@ -6,6 +6,7 @@ information provided here is intended especially for developers. * New auth hook - pre_user_login_hook() - available, triggered right after the user object is created. This can be used to modify the user object before any authentication errors are raised. * The block_login now displays the loginpage_idp_list() links as well as main login page. +* The authentication plugin auth_radius has been moved to the plugins database. === 3.0 === diff --git a/lib/classes/plugin_manager.php b/lib/classes/plugin_manager.php index 047ad738b90..99079390f71 100644 --- a/lib/classes/plugin_manager.php +++ b/lib/classes/plugin_manager.php @@ -1659,6 +1659,7 @@ class core_plugin_manager { // Moodle 2.3 supports upgrades from 2.2.x only. $plugins = array( 'qformat' => array('blackboard', 'learnwise'), + 'auth' => array('radius'), 'enrol' => array('authorize'), 'report' => array('search'), 'repository' => array('alfresco'), @@ -1713,8 +1714,7 @@ class core_plugin_manager { 'auth' => array( 'cas', 'db', 'email', 'fc', 'imap', 'ldap', 'lti', 'manual', 'mnet', - 'nntp', 'nologin', 'none', 'pam', 'pop3', 'radius', - 'shibboleth', 'webservice' + 'nntp', 'nologin', 'none', 'pam', 'pop3', 'shibboleth', 'webservice' ), 'availability' => array( diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 5367c1a2980..d6f0306c907 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2299,5 +2299,20 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2016101401.02); } + if ($oldversion < 2016102700.01) { + + // Force uninstall of deleted authentication plugin. + if (!file_exists("$CFG->dirroot/auth/radius")) { + // Leave settings inplace if there are radius users. + if (!$DB->record_exists('user', array('auth' => 'radius', 'deleted' => 0))) { + // Remove all other associated config. + unset_all_config_for_plugin('auth/radius'); + // The version number for radius is in this format. + unset_all_config_for_plugin('auth_radius'); + } + } + upgrade_main_savepoint(true, 2016102700.01); + } + return true; } diff --git a/lib/moodlelib.php b/lib/moodlelib.php index b9c10aebed9..c25acd3a390 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -317,7 +317,7 @@ define('PARAM_COMPONENT', 'component'); define('PARAM_AREA', 'area'); /** - * PARAM_PLUGIN is used for plugin names such as 'forum', 'glossary', 'ldap', 'radius', 'paypal', 'completionstatus'. + * PARAM_PLUGIN is used for plugin names such as 'forum', 'glossary', 'ldap', 'paypal', 'completionstatus'. * Only lowercase ascii letters, numbers and underscores are allowed, it has to start with a letter. * NOTE: numbers and underscores are strongly discouraged in plugin names! Underscores are forbidden in module names. */ diff --git a/version.php b/version.php index abc3bda27fe..5ccdc4e444f 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2016102700.00; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2016102700.01; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes.