mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 08:34:42 +01:00
added support for authentication via cookie. NOTE: you have to enable this in setup if u want to use it.
This commit is contained in:
parent
fd9d1b1ceb
commit
632a990cfb
72
login.php
72
login.php
@ -151,6 +151,20 @@
|
||||
{
|
||||
$passwd = $_POST['passwd'];
|
||||
$passwd_type = $_POST['passwd_type'];
|
||||
|
||||
if($GLOBALS['egw_info']['server']['allow_cookie_auth'])
|
||||
{
|
||||
$eGW_remember = unserialize(stripslashes($_COOKIE['eGW_remeber']));
|
||||
|
||||
if($eGW_remember['login'] && $eGW_remember['passwd'] && $eGW_remember['passwd_type'])
|
||||
{
|
||||
$_SERVER['PHP_AUTH_USER'] = $login = $eGW_remember['login'];
|
||||
$_SERVER['PHP_AUTH_PW'] = $passwd = $eGW_remember['passwd'];
|
||||
$passwd_type = $eGW_remember['passwd_type'];
|
||||
$submit = True;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# Apache + mod_ssl style SSL certificate authentication
|
||||
@ -192,6 +206,7 @@
|
||||
if(getenv('REQUEST_METHOD') != 'POST' && $_SERVER['REQUEST_METHOD'] != 'POST' &&
|
||||
!isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['SSL_CLIENT_S_DN']))
|
||||
{
|
||||
$GLOBALS['phpgw']->session->phpgw_setcookie('eGW_remeber');
|
||||
$GLOBALS['egw']->redirect($GLOBALS['egw']->link('/login.php','cd=5'));
|
||||
}
|
||||
#if(!isset($_COOKIE['eGroupWareLoginTime']))
|
||||
@ -233,10 +248,40 @@
|
||||
|
||||
if(!isset($GLOBALS['sessionid']) || ! $GLOBALS['sessionid'])
|
||||
{
|
||||
$GLOBALS['phpgw']->session->phpgw_setcookie('eGW_remeber');
|
||||
$GLOBALS['egw']->redirect($GLOBALS['egw_info']['server']['webserver_url'] . '/login.php?cd=' . $GLOBALS['egw']->session->cd_reason);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* set auth_cookie */
|
||||
if($GLOBALS['egw_info']['server']['allow_cookie_auth'] && $_POST['remember_me'] && $_POST['passwd'])
|
||||
{
|
||||
switch ($_POST['remember_me'])
|
||||
{
|
||||
case '1hour' :
|
||||
$remember_time = time()+60*60;
|
||||
break;
|
||||
case '1day' :
|
||||
$remember_time = time()+60*60*24;
|
||||
break;
|
||||
case '1week' :
|
||||
$remember_time = time()+60*60*24*7;
|
||||
break;
|
||||
case '1month' :
|
||||
$remember_time = time()+60*60*24*30;
|
||||
break;
|
||||
case 'forever' :
|
||||
default:
|
||||
$remember_time = 2147483647;
|
||||
break;
|
||||
}
|
||||
$GLOBALS['egw']->session->phpgw_setcookie('eGW_remeber',serialize(array(
|
||||
'login' => $login,
|
||||
'passwd' => $passwd,
|
||||
'passwd_type' => $passwd_type)),
|
||||
$remember_time);
|
||||
}
|
||||
|
||||
if ($_POST['lang'] && preg_match('/^[a-z]{2}(-[a-z]{2}){0,1}$/',$_POST['lang']) &&
|
||||
$_POST['lang'] != $GLOBALS['egw_info']['user']['preferences']['common']['lang'])
|
||||
{
|
||||
@ -399,6 +444,33 @@
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************\
|
||||
* Check if authentification via cookies is allowed *
|
||||
* and place a time selectbox, how long cookie is valid *
|
||||
\********************************************************/
|
||||
|
||||
if($GLOBALS['egw_info']['server']['allow_cookie_auth'])
|
||||
{
|
||||
$this->html = CreateObject('phpgwapi.html'); /* Why the hell was nobody useing this here before??? */
|
||||
$tmpl->set_block('login_form','remember_me_selection');
|
||||
$tmpl->set_var('lang_remember_me',lang('Remember me'));
|
||||
$tmpl->set_var('select_remember_me',$this->html->select('remember_me', 'forever', array(
|
||||
false => lang('not'),
|
||||
'1hour' => lang('1 Hour'),
|
||||
'1day' => lang('1 Day'),
|
||||
'1week'=> lang('1 Week'),
|
||||
'1month' => lang('1 Month'),
|
||||
'forever' => lang('Forever')),true
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* trick to make remember_me section disapear */
|
||||
$tmpl->set_block('login_form','remember_me_selection');
|
||||
$tmpl->set_var('remember_me_selection','');
|
||||
}
|
||||
|
||||
|
||||
// add a content-type header to overwrite an existing default charset in apache (AddDefaultCharset directiv)
|
||||
header('Content-type: text/html; charset='.$GLOBALS['egw']->translation->charset());
|
||||
|
||||
|
@ -55,6 +55,7 @@
|
||||
));
|
||||
}
|
||||
}
|
||||
$GLOBALS['phpgw']->session->phpgw_setcookie('eGW_remeber');
|
||||
$GLOBALS['phpgw']->session->phpgw_setcookie('sessionid');
|
||||
$GLOBALS['phpgw']->session->phpgw_setcookie('kp3');
|
||||
$GLOBALS['phpgw']->session->phpgw_setcookie('domain');
|
||||
|
@ -67,8 +67,10 @@
|
||||
// do we have to migrate an old password ?
|
||||
if($GLOBALS['egw_info']['server']['pwd_migration_allowed'])
|
||||
{
|
||||
if(!is_array($GLOBALS['egw_info']['server']['pwd_migration_types'])) return false;
|
||||
foreach($GLOBALS['egw_info']['server']['pwd_migration_types'] as $handle => $type)
|
||||
if(!isset($GLOBALS['egw_info']['server']['pwd_migration_types'])) return false;
|
||||
|
||||
$allowed_types = explode(',', $GLOBALS['egw_info']['server']['pwd_migration_types']);
|
||||
foreach($allowed_types as $num => $type)
|
||||
{
|
||||
if($this->compare_password($passwd,$this->db->f('account_pwd'),$type,strtolower($username)))
|
||||
{
|
||||
|
@ -89,6 +89,13 @@
|
||||
<td align="left"></td>
|
||||
</tr>
|
||||
<!-- END domain_selection -->
|
||||
<!-- BEGIN remember_me_selection -->
|
||||
<tr>
|
||||
<td align="right">{lang_remember_me}: </td>
|
||||
<td align="left" colspan="2">{select_remember_me}</td>
|
||||
</tr>
|
||||
<!-- END remember_me_selection -->
|
||||
|
||||
<tr>
|
||||
<td align="right" tablindex="1">{lang_username}: </td>
|
||||
<td align="left"><input name="login" value="{cookie}" style="width: 150px; border: 1px solid silver;"></td>
|
||||
|
@ -174,6 +174,33 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="row_off">
|
||||
<td>{lang_Allow_authentification_via_cookie}:</td>
|
||||
<td>
|
||||
<select name="newsettings[allow_cookie_auth]">
|
||||
<option value="">{lang_No}</option>
|
||||
<option value="True"{selected_allow_cookie_auth_True}>{lang_Yes}</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="row_on">
|
||||
<td>{lang_Allow_password_migration}:</td>
|
||||
<td>
|
||||
<select name="newsettings[pwd_migration_allowed]">
|
||||
<option value="">{lang_No}</option>
|
||||
<option value="True"{selected_pwd_migration_allowed_True}>{lang_Yes}</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="row_on">
|
||||
<td>{lang_Allowed_migration_types_(comma-separated)}:</td>
|
||||
<td>
|
||||
<input name="newsettings[pwd_migration_types]" value="{value_pwd_migration_types}" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="row_off">
|
||||
<td>{lang_Minimum_account_id_(e.g._500_or_100,_etc.)}:</td>
|
||||
<td><input name="newsettings[account_min_id]" value="{value_account_min_id}"></td>
|
||||
|
Loading…
Reference in New Issue
Block a user