From 78117f38bc1ef08438b6000869f7371301178f57 Mon Sep 17 00:00:00 2001 From: exe-cutor Date: Fri, 1 Feb 2008 08:30:17 +0000 Subject: [PATCH] Added integrated Shibboleth WAYF service on alternative login page Updated README --- auth/shibboleth/index_form.html | 99 +++++++++++++++++++++++++++++++++ auth/shibboleth/login.php | 80 ++++++++++++++++++++++++++ 2 files changed, 179 insertions(+) create mode 100644 auth/shibboleth/index_form.html create mode 100644 auth/shibboleth/login.php diff --git a/auth/shibboleth/index_form.html b/auth/shibboleth/index_form.html new file mode 100644 index 0000000000..4a65883038 --- /dev/null +++ b/auth/shibboleth/index_form.html @@ -0,0 +1,99 @@ + +
+
+ + +

login_name) && !empty($config->login_name)){ + echo $config->login_name; + } else { + print_string("auth_shibboleth_login_long", "auth"); + } + ?>

+
+
+ '; + formerr($errormsg); + echo '
'; + } + + ?> +
+

+
+

" accesskey="s" />

+
+

+ email.'"> Moodle Administrator.'; + ?> +

+
+
+
+ +guestloginbutton) { ?> +
+
+ +
+
+
+ + + + " /> +
+
+
+ +
+ + + +
+

+
+registerauth == 'email') { + if (!empty($CFG->auth_instructions)) { + echo format_text($CFG->auth_instructions); + } else { + print_string("loginsteps", "", "signup.php"); + } ?> +
+
+
" />
+
+
+registerauth)) { + echo format_text($CFG->auth_instructions); ?> +
+
+
" />
+
+
+auth_instructions); + } ?> +
+
+ + diff --git a/auth/shibboleth/login.php b/auth/shibboleth/login.php new file mode 100644 index 0000000000..32c1478120 --- /dev/null +++ b/auth/shibboleth/login.php @@ -0,0 +1,80 @@ +dirroot."/auth/shibboleth/auth.php"); + + //initialize variables + $errormsg = ''; + +/// Check for timed out sessions + if (!empty($SESSION->has_timed_out)) { + $session_has_timed_out = true; + $SESSION->has_timed_out = false; + } else { + $session_has_timed_out = false; + } + + +//HTTPS is potentially required in this page +httpsrequired(); + +/// Define variables used in page + if (!$site = get_site()) { + error("No site found!"); + } + + if (empty($CFG->langmenu)) { + $langmenu = ""; + } else { + $currlang = current_language(); + $langs = get_list_of_languages(); + $langlabel = get_accesshide(get_string('language')); + $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 providerId as argument + if (isset($IdPs[$selectedIdP][1]) && !empty($IdPs[$selectedIdP][1])){ + header('Location: '.$IdPs[$selectedIdP][1].'?providerId='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot.'/auth/shibboleth/index.php')); + } else { + header('Location: /Shibboleth.sso?providerId='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot.'/auth/shibboleth/index.php')); + } + } elseif (isset($_POST['idp']) && !isset($IdPs[$_POST['idp']])) { + $errormsg = get_string('auth_shibboleth_errormsg', 'auth'); + } + + $loginsite = get_string("loginsite"); + $navlinks = array(array('name' => $loginsite, 'link' => null, 'type' => 'misc')); + $navigation = build_navigation($navlinks); + $focus = 'idp'; + print_header("$site->fullname: $loginsite", $site->fullname, $navigation, $focus, + '', true, '
'.$langmenu.'
'); + + include("index_form.html"); + print_footer(); + +?> -- 2.39.5