[imp] patch for imp/lib/Auth/imp.php
Amith Varghese
amith at xalan.com
Wed Oct 22 13:25:25 PDT 2003
This patch enables hordeauth within IMP so that when you login, you don't have
to login twice when you have the hordeauth parameter set in servers.php.
Please e-mail me with any questions.
Thanks
Amith
-------------- next part --------------
Index: imp/lib/Auth/imp.php
===================================================================
RCS file: /repository/imp/lib/Auth/imp.php,v
retrieving revision 1.6
diff -u -r1.6 imp.php
--- imp/lib/Auth/imp.php 16 Sep 2003 23:05:09 -0000 1.6
+++ imp/lib/Auth/imp.php 22 Oct 2003 20:37:57 -0000
@@ -68,6 +68,55 @@
function authenticate($userID = null, $credentials = array(),
$login = false)
{
+
+ // check for for hordeauth
+ if (empty($_SESSION['imp']['uniquser'])) {
+
+ $autoLogin = IMP::canAutoLogin();
+ if ($autoLogin) {
+ $server_key = IMP::getAutoLoginServer();
+
+ require IMP_BASE . '/config/servers.php';
+
+ $hordeAuth = $servers[$server_key]['hordeauth'];
+ if (isset($hordeAuth)) {
+ $ptr = &$servers[$server_key];
+ $server = $ptr['server'];
+ $realm = $ptr['realm'];
+ $port = $ptr['port'];
+ $protocol = $ptr['protocol'];
+ $maildomain = $ptr['maildomain'];
+ $namespace = $ptr['namespace'];
+ $folders = $ptr['folders'];
+ if (strcasecmp($hordeAuth, 'full') == 0) {
+ $imapuser = Auth::getAuth();
+ } else {
+ $imapuser = Auth::getBareAuth();
+ }
+ $pass = Auth::getCredential('password');
+ $sessArray = array('realm' => $realm,
+ 'port' => $port,
+ 'protocol' => $protocol,
+ 'maildomain' => $maildomain,
+ 'namespace' => $namespace,
+ 'folders' => $folders);
+
+ require_once IMP_BASE . '/lib/Session.php';
+
+ if (IMP_Session::createSession($imapuser, $pass, $server,
+ $sessArray)) {
+ $entry = sprintf('Login success for %s [%s] to {%s:%s}',
+ $imapuser, $_SERVER['REMOTE_ADDR'],
+ $server, $port);
+ Horde::logMessage($entry, __FILE__, __LINE__,
+ PEAR_LOG_NOTICE);
+ IMP_Session::loginTasks();
+ return true;
+ }
+ }
+ }
+ }
+
if (empty($userID)) {
if (empty($_SESSION['imp']['uniquser'])) {
return false;
More information about the imp
mailing list