summaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2011-02-09 10:51:50 +0000
committerthomascube <thomas@roundcube.net>2011-02-09 10:51:50 +0000
commitb46e5b7407940499964d8a553c3eada05850f29d (patch)
tree882ffd6820097107176c1ba2e8341c0313f18ec2 /index.php
parent98cb0f179206843ceaa87df6bfb3d1da045ed8ad (diff)
Apply more bugfixes from trunk for 0.5.1
Diffstat (limited to 'index.php')
-rw-r--r--index.php21
1 files changed, 16 insertions, 5 deletions
diff --git a/index.php b/index.php
index 89066b58d..f4e2a55a1 100644
--- a/index.php
+++ b/index.php
@@ -75,6 +75,8 @@ $RCMAIL->action = $startup['action'];
// try to log in
if ($RCMAIL->task == 'login' && $RCMAIL->action == 'login') {
+ $request_valid = $_SESSION['temp'] && $RCMAIL->check_request(RCUBE_INPUT_POST, 'login');
+
// purge the session in case of new login when a session already exists
$RCMAIL->kill_session();
@@ -84,13 +86,14 @@ if ($RCMAIL->task == 'login' && $RCMAIL->action == 'login') {
'pass' => get_input_value('_pass', RCUBE_INPUT_POST, true,
$RCMAIL->config->get('password_charset', 'ISO-8859-1')),
'cookiecheck' => true,
+ 'valid' => $request_valid,
));
// check if client supports cookies
if ($auth['cookiecheck'] && empty($_COOKIE)) {
$OUTPUT->show_message("cookiesdisabled", 'warning');
}
- else if ($_SESSION['temp'] && !$auth['abort'] &&
+ else if ($auth['valid'] && !$auth['abort'] &&
!empty($auth['host']) && !empty($auth['user']) &&
$RCMAIL->login($auth['user'], $auth['pass'], $auth['host'])) {
// create new session ID
@@ -123,15 +126,15 @@ if ($RCMAIL->task == 'login' && $RCMAIL->action == 'login') {
else {
$error_code = is_object($IMAP) ? $IMAP->get_error_code() : -1;
- $OUTPUT->show_message($error_code < -1 ? 'imaperror' : 'loginfailed', 'warning');
+ $OUTPUT->show_message($error_code < -1 ? 'imaperror' : (!$auth['valid'] ? 'invalidrequest' : 'loginfailed'), 'warning');
$RCMAIL->plugins->exec_hook('login_failed', array(
'code' => $error_code, 'host' => $auth['host'], 'user' => $auth['user']));
$RCMAIL->kill_session();
}
}
-// end session
-else if ($RCMAIL->task == 'logout' && isset($_SESSION['user_id'])) {
+// end session (after optional referer check)
+else if ($RCMAIL->task == 'logout' && isset($_SESSION['user_id']) && (!$RCMAIL->config->get('referer_check') || rcube_check_referer())) {
$userdata = array('user' => $_SESSION['username'], 'host' => $_SESSION['imap_host'], 'lang' => $RCMAIL->user->language);
$OUTPUT->show_message('loggedout');
$RCMAIL->logout_actions();
@@ -167,7 +170,7 @@ if (empty($RCMAIL->user->ID)) {
);
}
- $OUTPUT->set_env('task', 'login');
+ $RCMAIL->set_task('login');
$OUTPUT->send('login');
}
// CSRF prevention
@@ -187,6 +190,14 @@ else {
$OUTPUT->show_message('invalidrequest', 'error');
$OUTPUT->send($RCMAIL->task);
}
+
+ // check referer if configured
+ if (!$request_check_whitelist[$RCMAIL->action] && $RCMAIL->config->get('referer_check') && !rcube_check_referer()) {
+ raise_error(array(
+ 'code' => 403,
+ 'type' => 'php',
+ 'message' => "Referer check failed"), true, true);
+ }
}
// handle special actions