diff --git a/auth/cas/auth.php b/auth/cas/auth.php index 42fc486ef5c..56e5a7de9fd 100644 --- a/auth/cas/auth.php +++ b/auth/cas/auth.php @@ -360,17 +360,27 @@ class auth_plugin_cas extends auth_plugin_ldap { * @return array List of arrays with keys url, iconurl and name. */ public function loginpage_idp_list($wantsurl) { - global $CFG; - $config = get_config('auth_cas'); - $params = ["authCAS" => "CAS"]; - $url = new moodle_url(get_login_url(), $params); - $iconurl = moodle_url::make_pluginfile_url(context_system::instance()->id, - 'auth_cas', - 'logo', - null, - '/', - $config->auth_logo); - $result[] = ['url' => $url, 'iconurl' => $iconurl, 'name' => $config->auth_name]; - return $result; + if (empty($this->config->hostname)) { + // CAS is not configured. + return []; + } + + $iconurl = moodle_url::make_pluginfile_url( + context_system::instance()->id, + 'auth_cas', + 'logo', + null, + '/', + $this->config->auth_logo); + + return [ + [ + 'url' => new moodle_url(get_login_url(), [ + 'authCAS' => 'CAS', + ]), + 'iconurl' => $iconurl, + 'name' => format_string($this->config->auth_name), + ], + ]; } } diff --git a/auth/cas/lang/en/auth_cas.php b/auth/cas/lang/en/auth_cas.php index 43e237a3968..3e465f9a612 100644 --- a/auth/cas/lang/en/auth_cas.php +++ b/auth/cas/lang/en/auth_cas.php @@ -27,6 +27,7 @@ $string['auth_cas_auth_name_description'] = 'Provide a name for the CAS authenti $string['auth_cas_auth_logo'] = 'Authentication method logo'; $string['auth_cas_auth_logo_description'] = 'Provide a logo for the CAS authentication method that is familiar to your users.'; $string['auth_cas_auth_user_create'] = 'Create users externally'; +$string['auth_cas_auth_service'] = 'CAS'; $string['auth_cas_baseuri'] = 'URI of the server (nothing if no baseUri)
For example, if the CAS server responds to host.domaine.fr/CAS/ then
cas_baseuri = CAS/'; $string['auth_cas_baseuri_key'] = 'Base URI'; $string['auth_cas_broken_password'] = 'You cannot proceed without changing your password, however there is no available page for changing it. Please contact your Moodle Administrator.'; diff --git a/auth/cas/lib.php b/auth/cas/lib.php index 124a354c970..7127556ccdf 100644 --- a/auth/cas/lib.php +++ b/auth/cas/lib.php @@ -15,33 +15,30 @@ // along with Moodle. If not, see . /** - * Authentication Plugin: CAS Authentication + * Authentication Plugin: CAS Authentication. * * Authentication using CAS (Central Authentication Server). * - * @package auth_cas - * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package auth_cas + * @copyright 2018 Fabrice Ménard + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - - defined('MOODLE_INTERNAL') || die; /** * Serves the logo file settings. * - - * @param stdClass $course course object - * @param stdClass $cm course module object - * @param stdClass $context context object - * @param string $filearea file area - * @param array $args extra arguments - * @param bool $forcedownload whether or not force download - * @param array $options additional options affecting the file serving - * @return bool false if file not found, does not return if found - justsend the file + * @param stdClass $course course object + * @param stdClass $cm course module object + * @param stdClass $context context object + * @param string $filearea file area + * @param array $args extra arguments + * @param bool $forcedownload whether or not force download + * @param array $options additional options affecting the file serving + * @return bool false|void */ -function auth_cas_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) { +function auth_cas_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = []) { if ($context->contextlevel != CONTEXT_SYSTEM) { return false; } @@ -50,26 +47,21 @@ function auth_cas_pluginfile($course, $cm, $context, $filearea, $args, $forcedow return false; } - $itemid = 0; - // Use the itemid to retrieve any relevant data records and perform any security checks to see if the - // user really does have access to the file in question. - // Extract the filename / filepath from the $args array. - $filename = array_pop($args); // The last item in the $args array. + $filename = array_pop($args); if (!$args) { - $filepath = '/'; // $args is empty => the path is '/' + $filepath = '/'; } else { - $filepath = '/'.implode('/', $args).'/'; // $args contains elements of the filepath + $filepath = '/' . implode('/', $args) . '/'; } // Retrieve the file from the Files API. + $itemid = 0; $fs = get_file_storage(); $file = $fs->get_file($context->id, 'auth_cas', $filearea, $itemid, $filepath, $filename); if (!$file) { return false; // The file does not exist. } - // We can now send the file back to the browser - in this case with a cache lifetime of 1 day and no filtering. - // From Moodle 2.3, use send_stored_file instead. send_stored_file($file, null, 0, $forcedownload, $options); } diff --git a/auth/cas/settings.php b/auth/cas/settings.php index 991f9d38a49..5434984b0c2 100644 --- a/auth/cas/settings.php +++ b/auth/cas/settings.php @@ -48,7 +48,9 @@ if ($ADMIN->fulltree) { // Authentication method name. $settings->add(new admin_setting_configtext('auth_cas/auth_name', get_string('auth_cas_auth_name', 'auth_cas'), - get_string('auth_cas_auth_name_description', 'auth_cas'), '', PARAM_RAW_TRIMMED)); + get_string('auth_cas_auth_name_description', 'auth_cas'), + get_string('auth_cas_auth_service', 'auth_cas'), + PARAM_RAW_TRIMMED)); // Authentication method logo. $opts = array('accepted_types' => array('.png', '.jpg', '.gif', '.webp', '.tiff', '.svg')); diff --git a/auth/cas/version.php b/auth/cas/version.php index f735c62d554..7c47f6a23ac 100644 --- a/auth/cas/version.php +++ b/auth/cas/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2018120300; // The current plugin version (Date: YYYYMMDDXX) +$plugin->version = 2018121400; // The current plugin version (Date: YYYYMMDDXX) $plugin->requires = 2018112800; // Requires this Moodle version $plugin->component = 'auth_cas'; // Full name of the plugin (used for diagnostics)