diff --git a/auth/shibboleth/README.txt b/auth/shibboleth/README.txt index 75baf634445..69736d01618 100644 --- a/auth/shibboleth/README.txt +++ b/auth/shibboleth/README.txt @@ -12,6 +12,7 @@ Changes: - 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 +- 10. 2005: Added better error messages and moved text to language directories Moodle Configuration with Dual login ------------------------------------------------------------------------------- @@ -151,7 +152,6 @@ Example file: // institution, street, zipcode, city and country $address = $_SERVER[$pluginconfig->field_map_address]; list($institution, $street, $zip_city) = split('\$', $address); - ereg(' (.+)',$zip_city, $regs); $city = $regs[1]; @@ -168,8 +168,7 @@ Example file: Bugs -------------------------------------------------------------------------------- -The current implementation has not yet been extensively tested. So there may be -bugs. Please send bug reports concerning the Shibboleth part to +Please send bug reports concerning the Shibboleth part to Lukas Haemmerle -------------------------------------------------------------------------------- diff --git a/auth/shibboleth/index.php b/auth/shibboleth/index.php index ef2cca021e9..0769d4ce69f 100644 --- a/auth/shibboleth/index.php +++ b/auth/shibboleth/index.php @@ -12,8 +12,8 @@ // Check whether Shibboleth is configured properly 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.'); - } + error(get_string( 'shib_not_set_up_error', 'auth')); + } /// If we can find the Shibboleth attribute, save it in session and return to main login page if (!empty($_SERVER[$pluginconfig->shib_user_attribute])) { // Shibboleth auto-login @@ -50,7 +50,16 @@ redirect($urltogo); } + } + + // If we can find any (user independent) Shibboleth attributes but no user + // attributes we probably didn't receive any user attributes + if ( !empty($_SERVER['HTTP_SHIB_APPLICATION_ID']) + && empty($_SERVER[$pluginconfig->shib_user_attribute])) + { + error(get_string( 'shib_no_attributes_error', 'auth' , '\''.$pluginconfig->shib_user_attribute.'\', \''.$pluginconfig->field_map_firstname.'\', \''.$pluginconfig->field_map_lastname.'\' and \''.$pluginconfig->field_map_email.'\'')); } + $SESSION->shibboleth_checked = true; // This will stop us bouncing back here diff --git a/auth/shibboleth/lib.php b/auth/shibboleth/lib.php index e6e288922cc..4a1ab72e56b 100755 --- a/auth/shibboleth/lib.php +++ b/auth/shibboleth/lib.php @@ -26,7 +26,6 @@ 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 @@ -36,7 +35,7 @@ function auth_get_userinfo($username) { || 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: '".$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."); + error(get_string( 'shib_not_all_attributes_error', 'auth' , "'".$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]."')")); } $attrmap = auth_shib_attributes(); @@ -47,18 +46,18 @@ function auth_get_userinfo($username) { foreach ($attrmap as $key=>$value) { $result[$key]=utf8_decode($_SERVER[$value]); } - + // Provide an API to modify the information to fit the Moodle internal // data representation if ( - $config["shib_convert_data"] - && $config["shib_convert_data"] != '' - && is_readable($config["shib_convert_data"]) + $pluginconfig->convert_data + && $pluginconfig->convert_data != '' + && is_readable($pluginconfig->convert_data) ){ // Include a custom file outside the Moodle dir to // modify the variable $moodleattributes - include($config["shib_convert_data"]); + include($pluginconfig->convert_data); } return $result; @@ -68,7 +67,6 @@ function auth_shib_attributes(){ //returns array containg attribute mappings between Moodle and shibboleth global $CFG; - $config = (array)$CFG; $pluginconfig = get_config('auth/shibboleth'); $pluginconfig = (array) $pluginconfig; @@ -82,7 +80,7 @@ function auth_shib_attributes(){ $moodleattributes[$field] = $pluginconfig["field_map_$field"]; } } - $moodleattributes['username']=$config["shib_user_attribute"]; + $moodleattributes['username']=$pluginconfig["shib_user_attribute"]; return $moodleattributes; } diff --git a/auth/shibboleth/shib-protected.php b/auth/shibboleth/shib-protected.php index 396e8e860a2..a3a9dfd944a 100755 --- a/auth/shibboleth/shib-protected.php +++ b/auth/shibboleth/shib-protected.php @@ -1,6 +1,19 @@ + AuthType shibboleth + ShibRequireSession On + require valid-user + +-- + +in your web server configuration. + +Consult moodle/auth/shibboleth/README.txt for further instructions. +*/ require_once("../../config.php"); header("Location: ".$CFG->wwwroot."/auth/shibboleth/");