Ejemplo n.º 1
0
    $langmenu = popup_form("{$CFG->httpswwwroot}/login/index.php?lang=", $langs, "chooselang", $currlang, "", "", "", true, 'self', $langlabel);
}
$loginsite = get_string("loginsite");
$loginurl = !empty($CFG->alternateloginurl) ? $CFG->alternateloginurl : '';
if (get_moodle_cookie() == '') {
    set_moodle_cookie('nobody');
    // To help search for cookies
}
if (!empty($CFG->registerauth) or is_enabled_auth('none') or !empty($CFG->auth_instructions)) {
    $show_instructions = true;
} else {
    $show_instructions = false;
}
// Set SAML domain cookie
$config = get_config('auth/shibboleth');
$IdPs = get_idp_list($config->organization_selection);
if (isset($_POST['idp']) && isset($IdPs[$_POST['idp']])) {
    $selectedIdP = $_POST['idp'];
    set_saml_cookie($selectedIdP);
    // Redirect to SessionInitiator with entityID as argument
    if (isset($IdPs[$selectedIdP][1]) && !empty($IdPs[$selectedIdP][1])) {
        // For Shibbolet 1.x Service Providers
        header('Location: ' . $IdPs[$selectedIdP][1] . '?providerId=' . urlencode($selectedIdP) . '&target=' . urlencode($CFG->wwwroot . '/auth/shibboleth/index.php'));
        // For Shibbolet 2.x Service Providers
        // header('Location: '.$IdPs[$selectedIdP][1].'?entityID='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot.'/auth/shibboleth/index.php'));
    } else {
        // For Shibbolet 1.x Service Providers
        header('Location: /Shibboleth.sso?providerId=' . urlencode($selectedIdP) . '&target=' . urlencode($CFG->wwwroot . '/auth/shibboleth/index.php'));
        // For Shibboleth 2.x Service Providers
        // header('Location: /Shibboleth.sso/DS?entityID='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot.'/auth/shibboleth/index.php'));
    }
Ejemplo n.º 2
0
 /**
  * Processes and stores configuration data for this authentication plugin.
  *
  *
  * @param object $config Configuration object
  */
 function process_config($config)
 {
     global $CFG;
     // set to defaults if undefined
     if (!isset($config->auth_instructions) or empty($config->user_attribute)) {
         $config->auth_instructions = get_string('auth_shib_instructions', 'auth_shibboleth', $CFG->wwwroot . '/auth/shibboleth/index.php');
     }
     if (!isset($config->user_attribute)) {
         $config->user_attribute = '';
     }
     if (!isset($config->convert_data)) {
         $config->convert_data = '';
     }
     if (!isset($config->changepasswordurl)) {
         $config->changepasswordurl = '';
     }
     if (!isset($config->login_name)) {
         $config->login_name = 'Shibboleth Login';
     }
     // Clean idp list
     if (isset($config->organization_selection) && !empty($config->organization_selection) && isset($config->alt_login) && $config->alt_login == 'on') {
         $idp_list = get_idp_list($config->organization_selection);
         if (count($idp_list) < 1) {
             return false;
         }
         $config->organization_selection = '';
         foreach ($idp_list as $idp => $value) {
             $config->organization_selection .= $idp . ', ' . $value[0] . ', ' . $value[1] . "\n";
         }
     }
     // save settings
     set_config('user_attribute', $config->user_attribute, 'auth/shibboleth');
     if (isset($config->organization_selection) && !empty($config->organization_selection)) {
         set_config('organization_selection', $config->organization_selection, 'auth/shibboleth');
     }
     set_config('logout_handler', $config->logout_handler, 'auth/shibboleth');
     set_config('logout_return_url', $config->logout_return_url, 'auth/shibboleth');
     set_config('login_name', $config->login_name, 'auth/shibboleth');
     set_config('convert_data', $config->convert_data, 'auth/shibboleth');
     set_config('auth_instructions', $config->auth_instructions, 'auth/shibboleth');
     set_config('changepasswordurl', $config->changepasswordurl, 'auth/shibboleth');
     // Overwrite alternative login URL if integrated WAYF is used
     if (isset($config->alt_login) && $config->alt_login == 'on') {
         set_config('alt_login', $config->alt_login, 'auth/shibboleth');
         set_config('alternateloginurl', $CFG->wwwroot . '/auth/shibboleth/login.php');
     } else {
         // Check if integrated WAYF was enabled and is now turned off
         // If it was and only then, reset the Moodle alternate URL
         if (isset($this->config->alt_login) and $this->config->alt_login == 'on') {
             set_config('alt_login', 'off', 'auth/shibboleth');
             set_config('alternateloginurl', '');
         }
         $config->alt_login = '******';
     }
     // Check values and return false if something is wrong
     // Patch Anyware Technologies (14/05/07)
     if ($config->convert_data != '' && (!file_exists($config->convert_data) || !is_readable($config->convert_data))) {
         return false;
     }
     // Check if there is at least one entry in the IdP list
     if (isset($config->organization_selection) && empty($config->organization_selection) && isset($config->alt_login) && $config->alt_login == 'on') {
         return false;
     }
     return true;
 }