mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
mnet MDL-21278 print a list of potential idps on the login page with links
this adds a new contract auth plugin method (implemented as empty in the base class)
This commit is contained in:
parent
c9606565ca
commit
b257d7c411
@ -1240,5 +1240,42 @@ class auth_plugin_mnet extends auth_plugin_base {
|
||||
return $logline;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a list of potential IdPs that this authentication plugin supports.
|
||||
* This is used to provide links on the login page.
|
||||
*
|
||||
* @param string $wantsurl the relative url fragment the user wants to get to. You can use this to compose a returnurl, for example
|
||||
*
|
||||
* @return array like:
|
||||
* array(
|
||||
* array(
|
||||
* 'url' => 'http://someurl',
|
||||
* 'icon' => new pix_icon(...),
|
||||
* 'name' => get_string('somename', 'auth_yourplugin'),
|
||||
* ),
|
||||
* )
|
||||
*/
|
||||
function loginpage_idp_list($wantsurl) {
|
||||
global $DB, $CFG;
|
||||
// strip off wwwroot, since the remote site will prefix it's return url with this
|
||||
$wantsurl = preg_replace('/(' . preg_quote($CFG->wwwroot, '/') . '|' . preg_quote($CFG->httpswwwroot, '/') . ')/', '', $wantsurl);
|
||||
if (!$hosts = $DB->get_records_sql('SELECT DISTINCT h.*, a.sso_jump_url,a.name as application
|
||||
FROM {mnet_host} h
|
||||
JOIN {mnet_host2service} m ON h.id=m.hostid
|
||||
JOIN {mnet_service} s ON s.id=m.serviceid
|
||||
JOIN {mnet_application} a ON h.applicationid = a.id
|
||||
WHERE s.name=? AND h.deleted=? AND m.publish = ?',
|
||||
array('sso_sp', 0, 1))) {
|
||||
return array();
|
||||
}
|
||||
$idps = array();
|
||||
foreach ($hosts as $host) {
|
||||
$idps[] = array(
|
||||
'url' => new moodle_url($host->wwwroot . $host->sso_jump_url, array('hostwwwroot' => $CFG->wwwroot, 'wantsurl' => $wantsurl, 'remoteurl' => 1)),
|
||||
'icon' => new pix_icon('i/' . $host->application . '_host', $host->name),
|
||||
'name' => $host->name,
|
||||
);
|
||||
}
|
||||
return $idps;
|
||||
}
|
||||
}
|
||||
|
@ -391,6 +391,7 @@ $string['auto_add_remote_users'] = 'Auto add remote users';
|
||||
$string['ntlmsso_attempting'] = 'Attempting Single Sign On via NTLM...';
|
||||
$string['ntlmsso_failed'] = 'Auto-login failed, try the normal login page...';
|
||||
$string['ntlmsso_isdisabled'] = 'NTLM SSO is disabled.';
|
||||
$string['potentialidps'] = 'Do you usually log in somewhere else before arriving here?<br />Choose from the following list to log in at your usual place:';
|
||||
$string['rpc_negotiation_timeout'] = 'RPC negotiation timeout';
|
||||
$string['shib_no_attributes_error'] = 'You seem to be Shibboleth authenticated but Moodle didn\'t receive any user attributes. Please check that your Identity Provider releases the necessary attributes ($a) to the Service Provider Moodle is running on or inform the webmaster of this server.';
|
||||
$string['shib_not_all_attributes_error'] = 'Moodle needs certain Shibboleth attributes which are not present in your case. The attributes are: $a<br />Please contact the webmaster of this server or your Identity Provider.';
|
||||
|
@ -440,5 +440,23 @@ class auth_plugin_base {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of potential IdPs that this authentication plugin supports.
|
||||
* This is used to provide links on the login page.
|
||||
*
|
||||
* @param string $wantsurl the relative url fragment the user wants to get to. You can use this to compose a returnurl, for example
|
||||
*
|
||||
* @return array like:
|
||||
* array(
|
||||
* array(
|
||||
* 'url' => 'http://someurl',
|
||||
* 'icon' => new pix_icon(...),
|
||||
* 'name' => get_string('somename', 'auth_yourplugin'),
|
||||
* ),
|
||||
* )
|
||||
*/
|
||||
function loginpage_idp_list($wantsurl) {
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -234,19 +234,6 @@ if (empty($CFG->usesid) and $testcookies and (get_moodle_cookie() == '')) { /
|
||||
$errormsg = get_string("invalidlogin");
|
||||
$errorcode = 3;
|
||||
}
|
||||
|
||||
if ( !empty($CFG->mnet_dispatcher_mode)
|
||||
&& $CFG->mnet_dispatcher_mode === 'strict'
|
||||
&& is_enabled_auth('mnet')
|
||||
&& $DB->record_exists_sql('SELECT h.id FROM {mnet_host} h
|
||||
INNER JOIN {mnet_host2service} m ON h.id=m.hostid
|
||||
INNER JOIN {mnet_service} s ON s.id=m.serviceid
|
||||
WHERE s.name=? AND h.deleted=? AND m.publish = ?',
|
||||
array('sso_sp', 0, 1))
|
||||
&& $DB->record_exists_select('user', 'username = ? AND mnethostid != ?', array($frm->username, $CFG->mnet_localhost_id))
|
||||
) {
|
||||
$errormsg .= get_string('loginlinkmnetuser', 'mnet', "mnet_email.php?u=$frm->username");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -317,6 +304,12 @@ if (!empty($CFG->registerauth) or is_enabled_auth('none') or !empty($CFG->auth_i
|
||||
$show_instructions = false;
|
||||
}
|
||||
|
||||
$potentialidps = array();
|
||||
foreach($authsequence as $authname) {
|
||||
$authplugin = get_auth_plugin($authname);
|
||||
$potentialidps = array_merge($potentialidps, $authplugin->loginpage_idp_list($SESSION->wantsurl));
|
||||
}
|
||||
|
||||
$PAGE->set_title("$site->fullname: $loginsite");
|
||||
$PAGE->set_heading("$site->fullname");
|
||||
$PAGE->set_focuscontrol($focus);
|
||||
|
@ -91,4 +91,14 @@ if ($show_instructions) {
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if (!empty($potentialidps)) { ?>
|
||||
<div class="subcontent potentialidps">
|
||||
<h6><?php print_string('potentialidps', 'auth'); ?></h6>
|
||||
<div class="potentialidplist">
|
||||
<?php foreach ($potentialidps as $idp) {
|
||||
echo '<div class="potentialidp"><a href="' . $idp['url']->out() . '" title="' . $idp['name'] . '">' . $OUTPUT->render($idp['icon'], $idp['name']) . ' ' . $idp['name'] . '</a></div>';
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once dirname(dirname(__FILE__)) . '/config.php';
|
||||
httpsrequired();
|
||||
|
||||
$username = required_param('u', PARAM_ALPHANUM);
|
||||
$sesskey = sesskey();
|
||||
|
||||
// if you are logged in then you shouldn't be here
|
||||
if (isloggedin() and !isguestuser()) {
|
||||
redirect( $CFG->wwwroot.'/', get_string('loginalready'), 5);
|
||||
}
|
||||
|
||||
$PAGE->set_url('/login/mnet_email.php', array('u'=>$username));
|
||||
|
||||
$mnetidprovider = get_string('mnetidprovider','mnet');
|
||||
$PAGE->navbar->add($mnetidprovider);
|
||||
$PAGE->set_title($mnetidprovider);
|
||||
$PAGE->set_heading($mnetidprovider);
|
||||
$PAGE->set_focuscontrol('email');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->notification(get_string('mnetidproviderdesc', 'mnet'));
|
||||
|
||||
if ($form = data_submitted() and confirm_sesskey()) {
|
||||
if ($user = $DB->get_record_select('user', 'username = ? AND email = ? AND mnethostid != ?', array($username,$form->email, $CFG->mnet_localhost_id))) {
|
||||
if (!empty($user->mnethostid) and $host = $DB->get_record('mnet_host', array('id'=>$user->mnethostid))) {
|
||||
$link = "<a href=\"{$host->wwwroot}/login/\">{$host->name}</a>";
|
||||
notice(get_string('mnetidprovidermsg','mnet',$link));
|
||||
}
|
||||
}
|
||||
if (empty($link)) {
|
||||
notice(get_string('mnetidprovidernotfound', 'mnet'));
|
||||
}
|
||||
}
|
||||
|
||||
echo '<p> </p>';
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthnormal');
|
||||
|
||||
?>
|
||||
<form method="post">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $sesskey; ?>">
|
||||
<?php echo get_string('email') ?>:
|
||||
<input type="text" name="email" id="email" size="" maxlength="100" />
|
||||
<input type="submit" value="<?php echo get_string('findlogin','mnet'); ?>" />
|
||||
</form>
|
||||
<?php
|
||||
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->footer();
|
@ -2944,13 +2944,23 @@ div.allcoursegrades {
|
||||
}
|
||||
|
||||
.loginbox .guestsub,
|
||||
.loginbox .forgotsub {
|
||||
.loginbox .forgotsub,
|
||||
.loginbox .potentialidps {
|
||||
border-top:1px solid;
|
||||
margin-left:12%;
|
||||
margin-right:12%;
|
||||
margin-bottom:5px;
|
||||
}
|
||||
|
||||
.loginbox .potentialidps .potentialidplist {
|
||||
margin-left:40%;
|
||||
}
|
||||
|
||||
.loginbox .potentialidps .potentialidplist div {
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
|
||||
.loginbox .loginform {
|
||||
margin-top:1em;
|
||||
text-align:left;
|
||||
|
Loading…
x
Reference in New Issue
Block a user