3 require_once("../../config.php");
4 require_once($CFG->dirroot
."/auth/shibboleth/auth.php");
9 /// Check for timed out sessions
10 if (!empty($SESSION->has_timed_out
)) {
11 $session_has_timed_out = true;
12 $SESSION->has_timed_out
= false;
14 $session_has_timed_out = false;
18 /// Define variables used in page
21 $loginsite = get_string("loginsite");
23 $loginurl = (!empty($CFG->alternateloginurl
)) ?
$CFG->alternateloginurl
: '';
26 if (!empty($CFG->registerauth
) or is_enabled_auth('none') or !empty($CFG->auth_instructions
)) {
27 $show_instructions = true;
29 $show_instructions = false;
32 // Set SAML domain cookie
33 $config = get_config('auth_shibboleth');
36 $IdPs = get_idp_list($config->organization_selection
);
37 if (isset($_POST['idp']) && isset($IdPs[$_POST['idp']])){
38 $selectedIdP = $_POST['idp'];
39 set_saml_cookie($selectedIdP);
41 // Redirect to SessionInitiator with entityID as argument
42 if (isset($IdPs[$selectedIdP][1]) && !empty($IdPs[$selectedIdP][1])) {
43 // For Shibbolet 1.x Service Providers
44 header('Location: '.$IdPs[$selectedIdP][1].'?providerId='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot
.'/auth/shibboleth/index.php'));
46 // For Shibbolet 2.x Service Providers
47 // header('Location: '.$IdPs[$selectedIdP][1].'?entityID='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot.'/auth/shibboleth/index.php'));
50 // For Shibbolet 1.x Service Providers
51 header('Location: /Shibboleth.sso?providerId='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot
.'/auth/shibboleth/index.php'));
53 // For Shibboleth 2.x Service Providers
54 // header('Location: /Shibboleth.sso/DS?entityID='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot.'/auth/shibboleth/index.php'));
56 } elseif (isset($_POST['idp']) && !isset($IdPs[$_POST['idp']])) {
57 $errormsg = get_string('auth_shibboleth_errormsg', 'auth_shibboleth');
60 $loginsite = get_string("loginsite");
62 $PAGE->set_url('/auth/shibboleth/login.php');
63 $PAGE->set_context(context_system
::instance());
64 $PAGE->navbar
->add($loginsite);
65 $PAGE->set_title("$site->fullname: $loginsite");
66 $PAGE->set_heading($site->fullname
);
68 echo $OUTPUT->header();
69 include("index_form.html");
70 echo $OUTPUT->footer();