From 57644359ef4ffe65b29e5e20482c354698fe614f Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 14 Oct 2009 05:01:14 -0600 Subject: [PATCH] Move more configuration to Horde. Remove 'realm' from server configuration (this should be done via the authentication hooks). Remove 'uniquser' (Horde_Auth::getAuth() returns the unique Horde user ID). --- imp/acl.php | 2 +- imp/compose.php | 2 +- imp/config/servers.php.dist | 16 ---------------- imp/docs/UPGRADING | 8 ++++++++ imp/lib/Application.php | 4 ---- imp/lib/Auth.php | 16 +++------------- imp/lib/Compose.php | 4 ++-- imp/lib/Spam.php | 2 +- imp/lib/UI/Compose.php | 2 +- 9 files changed, 17 insertions(+), 39 deletions(-) diff --git a/imp/acl.php b/imp/acl.php index 2cae5d076..d7d5b2494 100644 --- a/imp/acl.php +++ b/imp/acl.php @@ -124,7 +124,7 @@ if (empty($folder)) { } $curr_acl = $ACLDriver->getACL($folder); -$canEdit = $ACLDriver->canEdit($folder, $_SESSION['imp']['uniquser']); +$canEdit = $ACLDriver->canEdit($folder, Horde_Auth::getAuth()); require_once 'Horde/Prefs/UI.php'; diff --git a/imp/compose.php b/imp/compose.php index cffaeeedd..66824d5d1 100644 --- a/imp/compose.php +++ b/imp/compose.php @@ -880,7 +880,7 @@ if ($redirect) { $hidden = array( 'actionID' => '', - 'user' => $_SESSION['imp']['uniquser'], + 'user' => Horde_Auth::getAuth(), 'compose_requestToken' => Horde::getRequestToken('imp.compose'), 'compose_formToken' => Horde_Token::generateId('compose'), 'composeCache' => $composeCacheID, diff --git a/imp/config/servers.php.dist b/imp/config/servers.php.dist index 763b2bc43..d16900df4 100644 --- a/imp/config/servers.php.dist +++ b/imp/config/servers.php.dist @@ -187,22 +187,6 @@ * have an effect. By default, IMAP messages are output in the IMAP * server default language. (IMAP only) * - * realm: (string) ONLY USE REALM IF YOU ARE USING IMP FOR HORDE - * AUTHENTICATION, YOU HAVE MULTIPLE SERVERS, AND USERNAMES OVERLAP - * BETWEEN THOSE SERVERS. - * - * If you only have one server, or have multiple servers with no - * username clashes, or have full user@example.com usernames, you DO - * NOT need a realm setting. If realm is set, a '@' symbol plus the - * realm value will be appended to the username that users login to - * IMP with to create the username that Horde treats the user as. - * - * Example: with a realm of 'example.com', the username 'jane' would - * be treated by Horde (NOT your IMAP/POP server) as 'jane@example.com', - * and the username 'jane@example.com' would be treated as - * 'jane@example.com@example.com' - an occasion where you probably - * don't need a realm setting. - * * preferred: (string) Only useful if you want to use the same servers.php file * for different machines: if the hostname of the IMP machine is * identical to one of those in the preferred list, then the diff --git a/imp/docs/UPGRADING b/imp/docs/UPGRADING index 7f7b96033..f87673c6a 100644 --- a/imp/docs/UPGRADING +++ b/imp/docs/UPGRADING @@ -22,6 +22,14 @@ IMP only supports the FCKeditor javscript HTML GUI editor. Xinha is no longer supported. +Server Options +-------------- + +The 'realm' option has been removed. Altering usernames at runtime should +instead by accomplished by using Horde's authusername() and/or IMP's +preauthenticate() hooks. + + Configuration Options --------------------- diff --git a/imp/lib/Application.php b/imp/lib/Application.php index ca390f0da..a9d1e2df6 100644 --- a/imp/lib/Application.php +++ b/imp/lib/Application.php @@ -302,10 +302,6 @@ class IMP_Application extends Horde_Registry_Application $_SESSION['imp']['cache']['select_view'] = empty($credentials['imp_select_view']) ? '' : $credentials['imp_select_view']; - - /* Set the Horde ID, since it may have been altered by the 'realm' - * setting. */ - $credentials['auth_ob']->setCredential('userId', $_SESSION['imp']['uniquser']); } } diff --git a/imp/lib/Auth.php b/imp/lib/Auth.php index 8046f62d6..bef0036ff 100644 --- a/imp/lib/Auth.php +++ b/imp/lib/Auth.php @@ -131,11 +131,12 @@ class IMP_Auth break; } + $auth_id = Horde_Auth::getAuth(); $imap_ob = $GLOBALS['imp_imap']->ob(); $msg = sprintf( - $status_msg . ' for %s [%s]%s to {%s:%s [%s]}', - empty($_SESSION['imp']['uniquser']) ? '' : $_SESSION['imp']['uniquser'], + $status_msg . '%s [%s]%s to {%s:%s [%s]}', + $auth_id ? '' : ' for ' . $auth_id, $_SERVER['REMOTE_ADDR'], empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? '' : ' (forwarded for [' . $_SERVER['HTTP_X_FORWARDED_FOR'] . '])', $imap_ob ? $imap_ob->getParam('hostspec') : '', @@ -168,7 +169,6 @@ class IMP_Auth * 'smtp' -- SMTP options ('host' and 'port') * 'showunsub' -- Show unsusubscribed mailboxes on the folders screen. * 'tasklistavail' -- Is listing of tasklists available? - * 'uniquser' -- The unique user name. * 'view' -- The imp view mode (currently dimp, imp, or mimp) * * @param array $credentials An array of login credentials. @@ -198,16 +198,6 @@ class IMP_Auth throw new Horde_Auth_Exception('', Horde_Auth::REASON_FAILED); } - /* Determine the unique user name. */ - if (Horde_Auth::getAuth()) { - $_SESSION['imp']['uniquser'] = Horde_Auth::getOriginalAuth(); - } else { - $_SESSION['imp']['uniquser'] = $credentials['userId']; - if (!empty($ptr['realm'])) { - $_SESSION['imp']['uniquser'] .= '@' . $ptr['realm']; - } - } - /* Try authentication. */ try { self::authenticate(array( diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index 9b442c3d4..0013641df 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -554,7 +554,7 @@ class IMP_Compose } } - $entry = sprintf("%s Message sent to %s from %s", $_SERVER['REMOTE_ADDR'], $recipients, $_SESSION['imp']['uniquser']); + $entry = sprintf("%s Message sent to %s from %s", $_SERVER['REMOTE_ADDR'], $recipients, Horde_Auth::getAuth()); Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_INFO); /* Should we save this message in the sent mail folder? */ @@ -2423,7 +2423,7 @@ class IMP_Compose return; } - $filename = hash('md5', $_SESSION['imp']['uniquser']); + $filename = hash('md5', Horde_Auth::getAuth()); $vfs = VFS::singleton($GLOBALS['conf']['vfs']['type'], Horde::getDriverConfig('vfs', $GLOBALS['conf']['vfs']['type'])); if ($vfs->exists(self::VFS_DRAFTS_PATH, $filename)) { $data = $vfs->read(self::VFS_DRAFTS_PATH, $filename); diff --git a/imp/lib/Spam.php b/imp/lib/Spam.php index b958930e7..04727129a 100644 --- a/imp/lib/Spam.php +++ b/imp/lib/Spam.php @@ -136,7 +136,7 @@ class IMP_Spam if (!is_null($from_line)) { $spam_headers->addHeader('From', $from_line); } - $spam_headers->addHeader('Subject', sprintf(_("%s report from %s"), $action, $_SESSION['imp']['uniquser'])); + $spam_headers->addHeader('Subject', sprintf(_("%s report from %s"), $action, Horde_Auth::getAuth())); /* Send the message. */ try { diff --git a/imp/lib/UI/Compose.php b/imp/lib/UI/Compose.php index 2c21d014e..49bbb19ea 100644 --- a/imp/lib/UI/Compose.php +++ b/imp/lib/UI/Compose.php @@ -69,7 +69,7 @@ class IMP_UI_Compose } $entry = sprintf("%s Redirected message sent to %s from %s", - $_SERVER['REMOTE_ADDR'], $recipients, $_SESSION['imp']['uniquser']); + $_SERVER['REMOTE_ADDR'], $recipients, Horde_Auth::getAuth()); Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_INFO); if ($GLOBALS['conf']['sentmail']['driver'] != 'none') { -- 2.11.0