|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 require_once("../../config.php"); 00004 require_once($CFG->dirroot."/auth/shibboleth/auth.php"); 00005 00006 //initialize variables 00007 $errormsg = ''; 00008 00010 if (!empty($SESSION->has_timed_out)) { 00011 $session_has_timed_out = true; 00012 $SESSION->has_timed_out = false; 00013 } else { 00014 $session_has_timed_out = false; 00015 } 00016 00017 00018 //HTTPS is required in this page when $CFG->loginhttps enabled 00019 $PAGE->https_required(); 00020 00022 $site = get_site(); 00023 00024 $loginsite = get_string("loginsite"); 00025 00026 $loginurl = (!empty($CFG->alternateloginurl)) ? $CFG->alternateloginurl : ''; 00027 00028 00029 if (!empty($CFG->registerauth) or is_enabled_auth('none') or !empty($CFG->auth_instructions)) { 00030 $show_instructions = true; 00031 } else { 00032 $show_instructions = false; 00033 } 00034 00035 // Set SAML domain cookie 00036 $config = get_config('auth/shibboleth'); 00037 00038 00039 $IdPs = get_idp_list($config->organization_selection); 00040 if (isset($_POST['idp']) && isset($IdPs[$_POST['idp']])){ 00041 $selectedIdP = $_POST['idp']; 00042 set_saml_cookie($selectedIdP); 00043 00044 // Redirect to SessionInitiator with entityID as argument 00045 if (isset($IdPs[$selectedIdP][1]) && !empty($IdPs[$selectedIdP][1])) { 00046 // For Shibbolet 1.x Service Providers 00047 header('Location: '.$IdPs[$selectedIdP][1].'?providerId='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot.'/auth/shibboleth/index.php')); 00048 00049 // For Shibbolet 2.x Service Providers 00050 // header('Location: '.$IdPs[$selectedIdP][1].'?entityID='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot.'/auth/shibboleth/index.php')); 00051 00052 } else { 00053 // For Shibbolet 1.x Service Providers 00054 header('Location: /Shibboleth.sso?providerId='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot.'/auth/shibboleth/index.php')); 00055 00056 // For Shibboleth 2.x Service Providers 00057 // header('Location: /Shibboleth.sso/DS?entityID='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot.'/auth/shibboleth/index.php')); 00058 } 00059 } elseif (isset($_POST['idp']) && !isset($IdPs[$_POST['idp']])) { 00060 $errormsg = get_string('auth_shibboleth_errormsg', 'auth_shibboleth'); 00061 } 00062 00063 $loginsite = get_string("loginsite"); 00064 00065 $PAGE->set_url('/auth/shibboleth/login.php'); 00066 $PAGE->navbar->add($loginsite); 00067 $PAGE->set_title("$site->fullname: $loginsite"); 00068 $PAGE->set_heading($site->fullname); 00069 00070 echo $OUTPUT->header(); 00071 include("index_form.html"); 00072 echo $OUTPUT->footer(); 00073 00074