Modified Files:

hive/expired.php hive/lib.php tidy up login process
 Added Files:
 	hive/login.php  handle login request
This commit is contained in:
mikewaters
2005-07-29 08:06:01 +00:00
parent cc1a7a02e0
commit 5b561c2801
3 changed files with 70 additions and 29 deletions
+37 -17
View File
@@ -7,21 +7,41 @@
require_login();
if (empty($SESSION->HIVE_PASSWORD)) { // We don't have old password
error('Sorry, but Hive has timed out, you need to log in again',
$CFG->wwwroot.'/login/logout.php');
}
/// Try and log back in silently
if (sso_user_login($USER->username, $SESSION->HIVE_PASSWORD)) { // Log back into Hive
/// Need something in here to redirect back to Hive
} else {
error('Sorry, could not restore Hive connection, please try logging in again',
$CFG->wwwroot.'/login/logout.php');
}
//MW theres no easy way to log in seamlessly. We need the users unhashed password.
// It's a security risk to carry that in $SESSION so we put up login form.
print_header();
notify('Your Hive session has expired. Please reauthenticate using your usual Moodle login');
?>
<form action="login.php" method="post" name="login" id="login">
<table border="0" align="center">
<tr>
<td width="80%">
<table align="center" class="loginform">
<tr class="username">
<td align="right" class="c0">
<?php print_string("username") ?>:
</td>
<td class="c1">
<input type="text" name="username" size="15" value="<?php p($frm->username) ?>" alt="<?php print_string("username") ?>" />
</td>
</tr>
<tr class="password">
<td align="right" class="c0">
<?php print_string("password") ?>:
</td>
<td class="c1">
<input type="password" name="password" size="15" value="" alt="<?php print_string("password") ?>" />
</td>
</tr>
</table>
</td>
<td width="20%">
<input type="submit" value="<?php print_string("login") ?>" />
</td>
</tr>
</table>
</form>
<br />
<?php
close_window_button();
?>
+10 -12
View File
@@ -4,12 +4,12 @@
//
// Example CFG variables to make this work:
// $CFG->sso = 'hive';
// $CFG->hiveprot = 'http';
// $CFG->hiveport = '80';
// $CFG->hivehost = 'turkey.harvestroad.com.au';
// $CFG->hivepath = '/cgi-bin/hive/hivedb.cgi';
// $CFG->hivecbid = '28';
// $CFG->sso = 'hive';
// $CFG->hiveprotocol = 'http';
// $CFG->hiveport = '80';
// $CFG->hivehost = 'turkey.harvestroad.com.au';
// $CFG->hivepath = '/cgi-bin/hive/hive.cgi';
// $CFG->hivecbid = '28';
function sso_user_login($username, $password) {
@@ -25,30 +25,29 @@ function sso_user_login($username, $password) {
$snoopy = new Snoopy;
$submit_url = $CFG->hiveprot .'://'. $CFG->hivehost .':'. $CFG->hiveport .''. $CFG->hivepath ;
$submit_url = $CFG->hiveprotocol .'://'. $CFG->hivehost .':'. $CFG->hiveport .''. $CFG->hivepath ;
$submit_vars['HIVE_UNAME'] = $username;
$submit_vars['HIVE_UPASS'] = $password;
$submit_vars['HIVE_ENDUSER']= $username;
$submit_vars['HIVE_REQ'] = '2112';
$submit_vars['HIVE_REF'] = 'hin:hive@Moodle Login';
$submit_vars['HIVE_REF'] = 'hin:hive@API Login 3';
$submit_vars['HIVE_RET'] = 'ORG';
$submit_vars['HIVE_REM'] = '';
$submit_vars['HIVE_PROD'] = '0';
$submit_vars['HIVE_USERIP'] = getremoteaddr();
/// Ideally we use POST to call Hive with a bit more security
/// We use POST to call Hive with a bit more security
$snoopy->submit($submit_url,$submit_vars);
/// If there's a bug, we may need to use GET instead
/// foreach ($submit_vars as $name => $value) {
/// $params[] = "$name=".urlencode($value);
/// $params[] = "$name=".urlencode($value);
/// }
/// $submit_url .= '?'.implode('&', $params);
/// $snoopy->fetch($submit_url);
/// Extract HIVE_SESSION from headers
foreach ($snoopy->headers as $header) {
@@ -62,7 +61,6 @@ function sso_user_login($username, $password) {
}
}
}
return false; // No cookie found
}
+23
View File
@@ -0,0 +1,23 @@
<?php // $Id$
// login.php - action of the login form put up by expired.php.
require('../../config.php');
require('lib.php');
require_login();
// get the login data
$frm = data_submitted('');
// log back into Hive
if (sso_user_login($frm->username, $frm->password)) {
/// reopen Hive
redirect($CFG->wwwroot.'/mod/resource/type/repository/hive/openhive.php');
} else {
redirect($CFG->wwwroot.'/sso/hive/expired.php');
}
?>