Skip to content

Commit

Permalink
Added integrated Shibboleth WAYF service on alternative login page
Browse files Browse the repository at this point in the history
Updated README
  • Loading branch information
exe-cutor committed Feb 1, 2008
1 parent edc06a5 commit 78117f3
Show file tree
Hide file tree
Showing 2 changed files with 179 additions and 0 deletions.
99 changes: 99 additions & 0 deletions auth/shibboleth/index_form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php
$config = get_config('auth/shibboleth');

if ($show_instructions) {
$columns = 'twocolumns';
} else {
$columns = 'onecolumn';
}
?>
<div class="loginbox clearfix <?php echo $columns ?>">
<div class="loginpanel">
<!--<h2><?php print_string("returningtosite") ?></h2>-->

<h2><?php
if (isset($config->login_name) && !empty($config->login_name)){
echo $config->login_name;
} else {
print_string("auth_shibboleth_login_long", "auth");
}
?></h2>
<div class="subcontent loginsub">
<div class="desc">
<?php
if (!empty($errormsg)) {
echo '<div class="loginerrors">';
formerr($errormsg);
echo '</div>';
}

?>
<div class="guestsub">
<p><?php print_string("auth_shibboleth_select_organization", "auth"); ?></p>
<form action="login.php" method="post" id="guestlogin">
<select name="idp">
<option value="-" ><?php print_string("auth_shibboleth_select_member", "auth"); ?></option>
<?php
print_idp_list();
?>
</select><p><input type="submit" value="<?php print_string("select"); ?>" accesskey="s" /></p>
</form>
<p>
<?php
print_string("auth_shibboleth_contact_administrator", "auth");
echo '<a href="mailto:'.get_admin()->email.'"> Moodle Administrator</a>.';
?>
</p>
</div>
</div>
</div>

<?php if ($CFG->guestloginbutton) { ?>
<div class="subcontent guestsub">
<div class="desc">
<?php print_string("someallowguest") ?>
</div>
<form action="../../login/index.php" method="post" id="guestlogin">
<div class="guestform">
<input type="hidden" name="username" value="guest" />
<input type="hidden" name="password" value="guest" />
<input type="hidden" name="testcookies" value="1" />
<input type="submit" value="<?php print_string("loginguest") ?>" />
</div>
</form>
</div>
<?php } ?>
</div>


<?php if ($show_instructions) { ?>
<div class="signuppanel">
<h2><?php print_string("firsttime") ?></h2>
<div class="subcontent">
<?php if (is_enabled_auth('none')) { // instructions override the rest for security reasons
print_string("loginstepsnone");
} else if ($CFG->registerauth == 'email') {
if (!empty($CFG->auth_instructions)) {
echo format_text($CFG->auth_instructions);
} else {
print_string("loginsteps", "", "signup.php");
} ?>
<div class="signupform">
<form action="../../login/signup.php" method="get" id="signup">
<div><input type="submit" value="<?php print_string("startsignup") ?>" /></div>
</form>
</div>
<?php } else if (!empty($CFG->registerauth)) {
echo format_text($CFG->auth_instructions); ?>
<div class="signupform">
<form action="../../login/signup.php" method="get" id="signup">
<div><input type="submit" value="<?php print_string("startsignup") ?>" /></div>
</form>
</div>
<?php } else {
echo format_text($CFG->auth_instructions);
} ?>
</div>
</div>
<?php } ?>
</div>
80 changes: 80 additions & 0 deletions auth/shibboleth/login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php // $Id$


require_once("../../config.php");
require_once($CFG->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, '<div class="langmenu">'.$langmenu.'</div>');

include("index_form.html");
print_footer();

?>

0 comments on commit 78117f3

Please sign in to comment.