Hello,
What wish you to make with the patch #1388203 ?
* Integrate to svn trunk
* Integrate a global solution for alternative authentification
* maintain it as plug'in
* nothing !?
I join the diff of my patch for the last SVN (R460).
I use it in production since 3 weeks without problem.
Black Myst
Index: config/main.inc.php.dist
===================================================================
--- config/main.inc.php.dist (revision 460)
+++ config/main.inc.php.dist (working copy)
@@ -77,6 +77,9 @@
// best server supported one)
$rcmail_config['smtp_auth_type'] = '';
+// use http authentication : get login and pass from PHP variables
+$rcmail_config['http_authent'] = FALSE;
+
// Log sent messages
$rcmail_config['smtp_log'] = TRUE;
Index: program/include/main.inc
===================================================================
--- program/include/main.inc (revision 460)
+++ program/include/main.inc (working copy)
@@ -1312,7 +1312,7 @@
{
$incl = fread($fp, filesize($path));
fclose($fp);
- return parse_rcube_xml($incl);
+ return parse_rcube_xml(parse_rcube_conditions($incl));
}
break;
Index: program/steps/error.inc
===================================================================
--- program/steps/error.inc (revision 460)
+++ program/steps/error.inc (working copy)
@@ -35,6 +35,7 @@
<br />
» JavaScript enabled<br />
» Support for XMLHTTPRequest<br />
+» Allow cookies<br />
<p><i>Your configuration:</i><br />
$user_agent</p>
@@ -124,4 +125,4 @@
</html>
EOF;
-?>
\ No newline at end of file
+?>
Index: skins/default/includes/taskbar.html
===================================================================
--- skins/default/includes/taskbar.html (revision 460)
+++ skins/default/includes/taskbar.html (working copy)
@@ -2,5 +2,7 @@
<roundcube:button command="mail" label="mail" class="button-mail" />
<roundcube:button command="addressbook" label="addressbook" class="button-addressbook" />
<roundcube:button command="settings" label="settings" class="button-settings" />
+<roundcube:if condition="config:http_authent != true" />
<roundcube:button command="logout" label="logout" class="button-logout" />
-</div>
\ No newline at end of file
+<roundcube:endif />
+</div>
Index: index.php
===================================================================
--- index.php (revision 460)
+++ index.php (working copy)
@@ -162,8 +162,42 @@
}
+// try to log in if http_authent
+if ($CONFIG['http_authent'] && (!isset($_SESSION['user_id']) || !rcmail_authenticate_session()))
+ {
+ if (empty($_COOKIE) && !$_action=='login')
+ { // if no cookie, force reload the page to check if cookies is enabled.
+ header("Location: $COMM_PATH&_action=login");
+ exit;
+ }
+ else if (empty($_COOKIE) && $_action=='login')
+ { // if action login and no cookies: user has disabled cookies -> error
+ raise_error(
+ array('code' => 409,
+ 'type' => 'php',
+ 'message' => "User not allow cookies"),
+ FALSE,
+ TRUE);
+ }
+ else if (isset($_SERVER["PHP_AUTH_USER"]) && isset($_SERVER["PHP_AUTH_PW"]) &&
+ rcmail_login($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"],
+ rcmail_autoselect_host()))
+ {
+ // http_authent success
+ }
+ else
+ { // http_authent failed !
+ raise_error(
+ array('code' => 401,
+ 'type' => 'imap',
+ 'message' => "Http_authent faild for user :".$_SERVER['PHP_AUTH_USER']),
+ TRUE,
+ TRUE);
+ exit;
+ }
+ }
// try to log in
-if ($_action=='login' && $_task=='mail')
+else if (!$CONFIG['http_authent'] && $_action=='login' && $_task=='mail')
{
$host = rcmail_autoselect_host();
@@ -202,6 +236,11 @@
{
$message = show_message('sessionerror', 'error');
rcmail_kill_session();
+ if ($CONFIG['http_authent'] && isset($_SERVER["PHP_AUTH_USER"]) && isset($_SERVER["PHP_AUTH_PW"]))
+ { // With HTTP_authent, we can relog the user
+ rcmail_login($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"],
+ rcmail_autoselect_host());
+ }
}
}