Changeset 521 in subversion
- Timestamp:
- Mar 27, 2007 5:34:30 AM (6 years ago)
- Location:
- trunk/roundcubemail
- Files:
-
- 6 edited
-
CHANGELOG (modified) (1 diff)
-
UPGRADING (modified) (1 diff)
-
config/main.inc.php.dist (modified) (1 diff)
-
index.php (modified) (4 diffs)
-
program/include/main.inc (modified) (5 diffs)
-
program/include/session.inc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/CHANGELOG
r519 r521 1 1 CHANGELOG RoundCube Webmail 2 2 --------------------------- 3 4 2007/03/27 (thomasb) 5 ---------- 6 - New session authentication: Change sessid cookie when login, authentication with sessauth cookie is now configurable. 7 Should close bugs #1483951 and #1484299 8 3 9 4 10 2007/03/23 (thomasb) -
trunk/roundcubemail/UPGRADING
r434 r521 17 17 $rcmail_config['preview_pane'] = TRUE; 18 18 $rcmail_config['date_today'] = 'H:i'; 19 $rcmail_config['double_auth'] = TRUE; 19 20 20 21 -
trunk/roundcubemail/config/main.inc.php.dist
r423 r521 98 98 99 99 // check client IP in session athorization 100 $rcmail_config['ip_check'] = TRUE; 100 $rcmail_config['ip_check'] = false; 101 102 // Use an additional frequently changing cookie to athenticate user sessions. 103 // There have been problems reported with this feature. 104 $rcmail_config['double_auth'] = false; 101 105 102 106 // this key is used to encrypt the users imap password which is stored -
trunk/roundcubemail/index.php
r510 r521 3 3 +-----------------------------------------------------------------------+ 4 4 | RoundCube Webmail IMAP Client | 5 | Version 0.1-200703 01|5 | Version 0.1-20070327 | 6 6 | | 7 7 | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland | … … 41 41 */ 42 42 43 define('RCMAIL_VERSION', '0.1-200703 01');43 define('RCMAIL_VERSION', '0.1-20070327'); 44 44 45 45 // define global vars … … 173 173 show_message("cookiesdisabled", 'warning'); 174 174 } 175 else if ( isset($_POST['_user']) && isset($_POST['_pass']) &&175 else if ($_SESSION['temp'] && isset($_POST['_user']) && isset($_POST['_pass']) && 176 176 rcmail_login(get_input_value('_user', RCUBE_INPUT_POST), 177 177 get_input_value('_pass', RCUBE_INPUT_POST, true, 'ISO-8859-1'), $host)) 178 178 { 179 // create new session ID 180 unset($_SESSION['temp']); 181 sess_regenerate_id(); 182 183 // send auth cookie if necessary 184 rcmail_authenticate_session(); 185 179 186 // send redirect 180 187 header("Location: $COMM_PATH"); … … 198 205 else if ($_action != 'login' && $_SESSION['user_id'] && $_action != 'send') 199 206 { 200 if (!rcmail_authenticate_session() || 201 (!empty($CONFIG['session_lifetime']) && isset($SESS_CHANGED) && $SESS_CHANGED + $CONFIG['session_lifetime']*60 < mktime())) 207 if (!rcmail_authenticate_session()) 202 208 { 203 209 $message = show_message('sessionerror', 'error'); -
trunk/roundcubemail/program/include/main.inc
r515 r521 34 34 function rcmail_startup($task='mail') 35 35 { 36 global $sess_id, $sess_ auth, $sess_user_lang;36 global $sess_id, $sess_user_lang; 37 37 global $CONFIG, $INSTALL_PATH, $BROWSER, $OUTPUT, $_SESSION, $IMAP, $DB, $JS_OBJECT_NAME; 38 38 … … 54 54 $DB->db_connect('w'); 55 55 56 // we can use the database for storing session data 57 if (!$DB->is_error()) 58 include_once('include/session.inc'); 56 // use database for storing session data 57 include_once('include/session.inc'); 59 58 60 59 // init session … … 66 65 { 67 66 $_SESSION['user_lang'] = rcube_language_prop($CONFIG['locale_string']); 68 $_SESSION['auth_time'] = mktime();69 setcookie('sessauth', rcmail_auth_hash($sess_id, $_SESSION['auth_time']));67 $_SESSION['auth_time'] = time(); 68 $_SESSION['temp'] = true; 70 69 } 71 70 … … 179 178 function rcmail_authenticate_session() 180 179 { 181 $now = mktime(); 182 $valid = ($_COOKIE['sessauth'] == rcmail_auth_hash(session_id(), $_SESSION['auth_time']) || 183 $_COOKIE['sessauth'] == rcmail_auth_hash(session_id(), $_SESSION['last_auth'])); 184 185 // renew auth cookie every 5 minutes (only for GET requests) 186 if (!$valid || ($_SERVER['REQUEST_METHOD']!='POST' && $now-$_SESSION['auth_time'] > 300)) 187 { 188 $_SESSION['last_auth'] = $_SESSION['auth_time']; 189 $_SESSION['auth_time'] = $now; 190 setcookie('sessauth', rcmail_auth_hash(session_id(), $now)); 191 } 180 global $CONFIG, $SESS_CLIENT_IP, $SESS_CHANGED; 181 182 // advanced session authentication 183 if ($CONFIG['double_auth']) 184 { 185 $now = time(); 186 $valid = ($_COOKIE['sessauth'] == rcmail_auth_hash(session_id(), $_SESSION['auth_time']) || 187 $_COOKIE['sessauth'] == rcmail_auth_hash(session_id(), $_SESSION['last_auth'])); 188 189 // renew auth cookie every 5 minutes (only for GET requests) 190 if (!$valid || ($_SERVER['REQUEST_METHOD']!='POST' && $now-$_SESSION['auth_time'] > 300)) 191 { 192 $_SESSION['last_auth'] = $_SESSION['auth_time']; 193 $_SESSION['auth_time'] = $now; 194 setcookie('sessauth', rcmail_auth_hash(session_id(), $now)); 195 } 196 } 197 else 198 $valid = $CONFIG['ip_check'] ? $_SERVER['REMOTE_ADDR'] == $SESS_CLIENT_IP : true; 199 200 // check session filetime 201 if (!empty($CONFIG['session_lifetime']) && isset($SESS_CHANGED) && $SESS_CHANGED + $CONFIG['session_lifetime']*60 < time()) 202 $valid = false; 192 203 193 204 return $valid; … … 276 287 } 277 288 278 $_SESSION = array( );279 se ssion_destroy();289 $_SESSION = array('user_lang' => $GLOBALS['sess_user_lang'], 'auth_time' => time(), 'temp' => true); 290 setcookie('sessauth', '-del-', time()-60); 280 291 } 281 292 -
trunk/roundcubemail/program/include/session.inc
r339 r521 37 37 function sess_read($key) 38 38 { 39 global $DB, $SESS_CHANGED; 39 global $DB, $SESS_CHANGED, $SESS_CLIENT_IP; 40 41 if ($DB->is_error()) 42 return FALSE; 40 43 41 44 $sql_result = $DB->query("SELECT vars, ip, ".$DB->unixtimestamp('changed')." AS changed … … 47 50 { 48 51 $SESS_CHANGED = $sql_arr['changed']; 52 $SESS_CLIENT_IP = $sql_arr['ip']; 49 53 50 54 if (strlen($sql_arr['vars'])) … … 60 64 { 61 65 global $DB; 66 67 if ($DB->is_error()) 68 return FALSE; 62 69 63 70 $sql_result = $DB->query("SELECT 1 … … 97 104 global $DB; 98 105 106 if ($DB->is_error()) 107 return FALSE; 108 99 109 // delete session entries in cache table 100 110 $DB->query("DELETE FROM ".get_table_name('cache')." … … 114 124 { 115 125 global $DB; 126 127 if ($DB->is_error()) 128 return FALSE; 116 129 117 130 // get all expired sessions … … 145 158 146 159 160 function sess_regenerate_id() 161 { 162 $randlen = 32; 163 $randval = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 164 $random = ""; 165 for ($i=1; $i <= $randlen; $i++) 166 $random .= substr($randval, rand(0,(strlen($randval) - 1)), 1); 167 168 // use md5 value for id or remove capitals from string $randval 169 $random = md5($random); 170 171 // delete old session record 172 sess_destroy(session_id()); 173 174 session_id($random); 175 $cookie = session_get_cookie_params(); 176 setcookie(session_name(), $random, $cookie['lifetime'], $cookie['path']); 177 178 return true; 179 } 180 181 147 182 // set custom functions for PHP session management 148 183 session_set_save_handler('sess_open', 'sess_close', 'sess_read', 'sess_write', 'sess_destroy', 'sess_gc');
Note: See TracChangeset
for help on using the changeset viewer.
