Merging fixes from MOODLE_15
This commit is contained in:
@@ -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 <[email protected]> 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:
|
||||
<?PHP
|
||||
|
||||
// Set the zip code and the adress
|
||||
if ($_SERVER[$CFG->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);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
// Set default values
|
||||
if (!isset($config->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, '');
|
||||
|
||||
?>
|
||||
<tr>
|
||||
@@ -17,33 +17,10 @@ optional_variable($config->shib_convert_data, 0);
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<!--
|
||||
<tr>
|
||||
<td align="right"><?php print_string("auth_shib_only", "auth") ?>:</td>
|
||||
<td>
|
||||
<select name="auth_shib_only">
|
||||
<option value="0" <?php echo ($config->auth_shib_only ? '' : 'selected="yes"') ?> >
|
||||
<?php print_string("no") ?></option>
|
||||
<option value="1" <?php echo ($config->auth_shib_only ? 'selected="yes"' : '') ?> >
|
||||
<?php print_string("yes") ?></option>
|
||||
</select>
|
||||
</td>
|
||||
<td><?php print_string("auth_shib_only_description", "auth") ?></td>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td align="right">Shibboleth logout url ():</td>
|
||||
<td>
|
||||
<input name="shib_logout_url" type="text" size="30" value="<?php echo $config->shib_logout_url?>">
|
||||
</td>
|
||||
<td></td> </td>
|
||||
</tr>
|
||||
-->
|
||||
<tr valign="top" class="required">
|
||||
<td align="right"><?php print_string("username") ?>:</td>
|
||||
<td>
|
||||
<input name="shib_user_attribute" type="text" size="30" value="<?php echo $config->shib_user_attribute?>">
|
||||
<input name="pluginconfig_shib_user_attribute" type="text" size="30" value="<?php echo $pluginconfig->shib_user_attribute ?>">
|
||||
</td>
|
||||
<td></td>
|
||||
</td>
|
||||
@@ -64,9 +41,9 @@ optional_variable($config->shib_convert_data, 0);
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("auth_shib_convert_data", "auth") ?>:</td>
|
||||
<td>
|
||||
<input name="shib_convert_data" type="text" size="30" value="<?php echo $config->shib_convert_data?>">
|
||||
<input name="pluginconfig_convert_data" type="text" size="30" value="<?php echo $pluginconfig->convert_data?>">
|
||||
<?
|
||||
if ($config->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 '<br><font color="red">';
|
||||
print_string("auth_shib_convert_data_warning", "auth");
|
||||
echo '</font>';
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
+19
-15
@@ -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]."')<br>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]."')<br>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;
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user