diff --git a/auth/shibboleth/README.txt b/auth/shibboleth/README.txt index 6a3827a907f..75baf634445 100644 --- a/auth/shibboleth/README.txt +++ b/auth/shibboleth/README.txt @@ -2,12 +2,16 @@ Shibboleth Authentication for Moodle ------------------------------------------------------------------------------- Requirements: -- Moodle 1.5 or later. Versions prior to 1.5 may also work with Shibboleth - authentication (contact Lukas Haemmerle for further - instructions) +- Moodle 1.5 or later - Shibboleth target 1.1 or later. See documentation for your Shibboleth federation on how to set up Shibboleth. -- Modifications to login process by Martin Dougiamas + +Changes: +- 11. 2004: Created by Markus Hagman +- 05. 2005: Modifications to login process by Martin Dougiamas +- 05. 2005: Various extensions and fixes by Lukas Haemmerle +- 06. 2005: Adaptions to new field locks and plugin config structures by Marting + Langhoff and Lukas Haemmerle Moodle Configuration with Dual login ------------------------------------------------------------------------------- @@ -140,12 +144,12 @@ Example file: auth_shib_user_address] != '') + if ($_SERVER[$pluginconfig->field_map_address] != '') { // $address contains something like 'SWITCH$Limmatquai 138$CH-8021 Zurich' // We want to split this up to get: // institution, street, zipcode, city and country - $address = $_SERVER[$CFG->auth_shib_user_address]; + $address = $_SERVER[$pluginconfig->field_map_address]; list($institution, $street, $zip_city) = split('\$', $address); ereg(' (.+)',$zip_city, $regs); diff --git a/auth/shibboleth/config.html b/auth/shibboleth/config.html index 2805086d635..244fb555b60 100755 --- a/auth/shibboleth/config.html +++ b/auth/shibboleth/config.html @@ -1,13 +1,13 @@ auth_instructions) or empty($config->shib_user_attribute)) { +$pluginconfig = get_config('auth/shibboleth'); + +if (!isset($config->auth_instructions) or empty($pluginconfig->shib_user_attribute)) { $config->auth_instructions = get_string('auth_shib_instructions', 'auth', $CFG->wwwroot.'/auth/shibboleth/shib-protected.php'); } -optional_variable($config->auth_shib_only, 0); -optional_variable($config->shib_user_attribute, ''); -optional_variable($config->shib_logout_url, ''); -optional_variable($config->shib_convert_data, 0); +optional_variable($pluginconfig->user_attribute, ''); +optional_variable($pluginconfig->convert_data, ''); ?> @@ -17,33 +17,10 @@ optional_variable($config->shib_convert_data, 0);

- : - + @@ -64,9 +41,9 @@ optional_variable($config->shib_convert_data, 0); : - + shib_convert_data && $config->shib_convert_data != '' && !is_readable($config->shib_convert_data)){ + if ($pluginconfig->convert_data && $pluginconfig->convert_data != '' && !is_readable($pluginconfig->convert_data)){ echo '
'; print_string("auth_shib_convert_data_warning", "auth"); echo ''; diff --git a/auth/shibboleth/index.php b/auth/shibboleth/index.php index 728853dd962..d73c00ed964 100644 --- a/auth/shibboleth/index.php +++ b/auth/shibboleth/index.php @@ -8,15 +8,17 @@ redirect($CFG->wwwroot.'/index.php'); } + $pluginconfig = get_config('auth/shibboleth'); + // Check whether Shibboleth is configured properly - if (empty($CFG->shib_user_attribute)) { + if (empty($pluginconfig->shib_user_attribute)) { error('Shibboleth authentication (\'shib_user_attribute\') is not set up correctly. You probably haven\'t yet configured the Shibboleth authentication. Please consult the README in moodle/auth/shibboleth for further instructions on how to set up Shibboleth authentication.'); } /// If we can find the Shibboleth attribute, save it in session and return to main login page - if (!empty($_SERVER[$CFG->shib_user_attribute])) { // Shibboleth auto-login - $frm->username = $_SERVER[$CFG->shib_user_attribute]; - $frm->password = substr(base64_encode($_SERVER[$CFG->shib_user_attribute]),0,8); + if (!empty($_SERVER[$pluginconfig->shib_user_attribute])) { // Shibboleth auto-login + $frm->username = $_SERVER[$pluginconfig->shib_user_attribute]; + $frm->password = substr(base64_encode($_SERVER[$pluginconfig->shib_user_attribute]),0,8); // The random password consists of the first 8 letters of the base 64 encoded user ID // This password is never used unless the user account is converted to manual diff --git a/auth/shibboleth/lib.php b/auth/shibboleth/lib.php index d9a2fee02eb..e6e288922cc 100755 --- a/auth/shibboleth/lib.php +++ b/auth/shibboleth/lib.php @@ -6,9 +6,11 @@ function auth_user_login($username, $password) { global $CFG; + $pluginconfig = get_config('auth/shibboleth'); + /// If we are in the shibboleth directory then we trust the server var - if (!empty($_SERVER[$CFG->shib_user_attribute])) { - return ($_SERVER[$CFG->shib_user_attribute] == $username); + if (!empty($_SERVER[$pluginconfig->shib_user_attribute])) { + return ($_SERVER[$pluginconfig->shib_user_attribute] == $username); } /// If we are not, then the server is probably set to not be Shibboleth-only @@ -24,19 +26,21 @@ function auth_get_userinfo($username) { // reads user information from shibboleth attributes and return it in array() global $CFG; + $config = (array)$CFG; + $pluginconfig = get_config('auth/shibboleth'); + // Check whether we have got all the essential attributes if ( - empty($_SERVER[$CFG->shib_user_attribute]) - || empty($_SERVER[$CFG->auth_shib_user_firstname]) - || empty($_SERVER[$CFG->auth_shib_user_lastname]) - || empty($_SERVER[$CFG->auth_shib_user_email]) + empty($_SERVER[$pluginconfig->shib_user_attribute]) + || empty($_SERVER[$pluginconfig->field_map_firstname]) + || empty($_SERVER[$pluginconfig->field_map_lastname]) + || empty($_SERVER[$pluginconfig->field_map_email]) ) { - error("Moodle needs certain Shibboleth attributes which are not present in your case. The attributes are: '".$CFG->shib_user_attribute."' ('".$_SERVER[$CFG->shib_user_attribute]."'), '".$CFG->auth_shib_user_firstname."' ('".$_SERVER[$CFG->auth_shib_user_firstname]."'), '".$CFG->auth_shib_user_lastname."' ('".$_SERVER[$CFG->auth_shib_user_lastname]."') and '".$CFG->auth_shib_user_email."' ('".$_SERVER[$CFG->auth_shib_user_email]."')
Please contact your Identity Service Provider."); + error("Moodle needs certain Shibboleth attributes which are not present in your case. The attributes are: '".$pluginconfig->shib_user_attribute."' ('".$_SERVER[$pluginconfig->shib_user_attribute]."'), '".$pluginconfig->field_map_firstname."' ('".$_SERVER[$pluginconfig->field_map_firstname]."'), '".$pluginconfig->field_map_lastname."' ('".$_SERVER[$pluginconfig->field_map_lastname]."') and '".$pluginconfig->field_map_email."' ('".$_SERVER[$pluginconfig->field_map_email]."')
Please contact your Identity Service Provider."); } - $config = (array)$CFG; $attrmap = auth_shib_attributes(); - + $result = array(); $search_attribs = array(); @@ -60,13 +64,13 @@ function auth_get_userinfo($username) { return $result; } -function auth_shib_attributes (){ +function auth_shib_attributes(){ //returns array containg attribute mappings between Moodle and shibboleth global $CFG; $config = (array)$CFG; - $pcfg = get_config('auth/shibboleth'); - $pcfg = (array) $pcfg; + $pluginconfig = get_config('auth/shibboleth'); + $pluginconfig = (array) $pluginconfig; $fields = array("firstname", "lastname", "email", "phone1", "phone2", "department", "address", "city", "country", "description", @@ -74,12 +78,12 @@ function auth_shib_attributes (){ $moodleattributes = array(); foreach ($fields as $field) { - if ($pcfg["auth_shib_user_$field"]) { - $moodleattributes[$field] = $pcfg["auth_shib_user_$field"]; + if ($pluginconfig["field_map_$field"]) { + $moodleattributes[$field] = $pluginconfig["field_map_$field"]; } } $moodleattributes['username']=$config["shib_user_attribute"]; - + return $moodleattributes; } ?>