diff --git a/build/owncloud/rainloop-app/INSTALL b/build/owncloud/rainloop-app/INSTALL index 8530ca907..c24813c89 100644 --- a/build/owncloud/rainloop-app/INSTALL +++ b/build/owncloud/rainloop-app/INSTALL @@ -10,7 +10,7 @@ ************************************************************************ REQUIREMENTS: -- Installed and configured RainLoop Webmail +- Installed and configured RainLoop Webmail (standalone) - ownCloud version 6 or higher - Both apps (RainLoop & ownCloud) running on the same domain @@ -20,17 +20,7 @@ INSTALL: CONFIGURATION: - -- RainLoop: - 1) Open ../_default_/configs/application.ini - 2) Find: - -[labs] -allow_external_sso = On -external_sso_key = "super-secret-key" - - ownCloud: 1) In the Apps > Enable 'RainLoop' plugin - 2) In the Settings > Admin > Enter "RainLoop Webmail URL" and "SSO key" + 2) In the Settings > Admin > Enter "RainLoop Webmail URL" and "Absolute file path to RainLoop Webmail installation" 3) In the Settings > Personal > Type your mail server email (login) and password - diff --git a/build/owncloud/rainloop-app/admin.php b/build/owncloud/rainloop-app/admin.php index 204093702..1e8b0633e 100644 --- a/build/owncloud/rainloop-app/admin.php +++ b/build/owncloud/rainloop-app/admin.php @@ -15,5 +15,5 @@ OCP\Util::addScript('rainloop', 'admin'); $oTemplate = new OCP\Template('rainloop', 'admin'); $oTemplate->assign('rainloop-url', OCP\Config::getAppValue('rainloop', 'rainloop-url', '')); -$oTemplate->assign('rainloop-sso-key', OCP\Config::getAppValue('rainloop', 'rainloop-sso-key', '')); +$oTemplate->assign('rainloop-path', OCP\Config::getAppValue('rainloop', 'rainloop-path', '')); return $oTemplate->fetchPage(); diff --git a/build/owncloud/rainloop-app/ajax/admin.php b/build/owncloud/rainloop-app/ajax/admin.php index 6c27cf94f..911d54a60 100644 --- a/build/owncloud/rainloop-app/ajax/admin.php +++ b/build/owncloud/rainloop-app/ajax/admin.php @@ -14,20 +14,21 @@ OCP\JSON::checkAppEnabled('rainloop'); OCP\JSON::callCheck(); $sUrl = ''; -$sSsoKey = ''; -if (isset($_POST['appname'], $_POST['rainloop-url'], $_POST['rainloop-sso-key']) && 'rainloop' === $_POST['appname']) +$sPath = ''; + +if (isset($_POST['appname'], $_POST['rainloop-url'], $_POST['rainloop-path']) && 'rainloop' === $_POST['appname']) { OCP\Config::setAppValue('rainloop', 'rainloop-url', $_POST['rainloop-url']); - OCP\Config::setAppValue('rainloop', 'rainloop-sso-key', $_POST['rainloop-sso-key']); + OCP\Config::setAppValue('rainloop', 'rainloop-path', $_POST['rainloop-path']); $sUrl = OCP\Config::getAppValue('rainloop', 'rainloop-url', ''); - $sSsoKey = OCP\Config::getAppValue('rainloop', 'rainloop-sso-key', ''); + $sPath = OCP\Config::getAppValue('rainloop', 'rainloop-path', ''); } else { - OC_JSON::error(array('Message' => 'Invalid Argument(s)', 'Url' => $sUrl, 'SsoKey' => $sSsoKey)); + OC_JSON::error(array('Message' => 'Invalid Argument(s)', 'Url' => $sUrl, 'Path' => $sPath)); return false; } -OCP\JSON::success(array('Message' => 'Saved successfully', 'Url' => $sUrl, 'SsoKey' => $sSsoKey)); +OCP\JSON::success(array('Message' => 'Saved successfully', 'Url' => $sUrl, 'Path' => $sPath)); return true; diff --git a/build/owncloud/rainloop-app/index.php b/build/owncloud/rainloop-app/index.php index 78a442262..97f5b00ad 100644 --- a/build/owncloud/rainloop-app/index.php +++ b/build/owncloud/rainloop-app/index.php @@ -14,9 +14,9 @@ OCP\App::checkAppEnabled('rainloop'); OCP\App::setActiveNavigationEntry('rainloop_index'); $sUrl = trim(OCP\Config::getAppValue('rainloop', 'rainloop-url', '')); -$sSsoKey = trim(OCP\Config::getAppValue('rainloop', 'rainloop-sso-key', '')); +$sPath = trim(OCP\Config::getAppValue('rainloop', 'rainloop-path', '')); -if ('' === $sUrl || '' === $sSsoKey) +if ('' === $sUrl || '' === $sPath) { $oTemplate = new OCP\Template('rainloop', 'index-empty', 'user'); } @@ -27,19 +27,14 @@ else $sUser = OCP\User::getUser(); $sEmail = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-email', ''); - $sLogin = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-login', ''); $sPassword = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-password', ''); - $sUrl = \rtrim($sUrl, '/\\'); - if ('.php' !== \strtolower(\substr($sUrl), -4)) - { - $sUrl .= '/'; - } include_once OC_App::getAppPath('rainloop').'/lib/RainLoopHelper.php'; - $sPassword = OC_RainLoop_Helper::decodePassword($sPassword, md5($sEmail.$sLogin)); - $sSsoHash = OC_RainLoop_Helper::getSsoHash($sUrl, $sSsoKey, $sEmail, $sPassword, $sLogin); + $sPassword = OC_RainLoop_Helper::decodePassword($sPassword, md5($sEmail)); + $sSsoHash = OC_RainLoop_Helper::getSsoHash($sPath, $sEmail, $sPassword); + $sUrl = OC_RainLoop_Helper::normalizeUrl($sUrl); $sResultUrl = empty($sSsoHash) ? $sUrl.'?sso' : $sUrl.'?sso&hash='.$sSsoHash; $oTemplate = new OCP\Template('rainloop', 'index', 'user'); diff --git a/build/owncloud/rainloop-app/lib/RainLoopHelper.php b/build/owncloud/rainloop-app/lib/RainLoopHelper.php index 5efdea9f2..b2449e870 100644 --- a/build/owncloud/rainloop-app/lib/RainLoopHelper.php +++ b/build/owncloud/rainloop-app/lib/RainLoopHelper.php @@ -2,37 +2,47 @@ class OC_RainLoop_Helper { - public static function getSsoHash($sUrl, $sSsoKey, $sEmail, $sPassword) + /** + * @param string $sPath + * @param string $sEmail + * @param string $sPassword + * + * @return string + */ + public static function getSsoHash($sPath, $sEmail, $sPassword) { - if (!function_exists('curl_init')) + $SsoHash = ''; + + $sPath = rtrim(trim($sPath), '\\/').'/index.php'; + if (file_exists($sPath)) { - return ''; + $_ENV['RAINLOOP_INCLUDE_AS_API'] = false; + include $sPath; + + if (class_exists($sPath)) + { + + $SsoHash = \RainLoop\Api::GetUserSsoHash($sEmail, $sPassword); + } + } + + return $SsoHash; + } + + /** + * @param string $sUrl + * + * @return string + */ + public static function normalizeUrl($sUrl) + { + $sUrl = \rtrim($sUrl, '/\\'); + if ('.php' !== \strtolower(\substr($sUrl), -4)) + { + $sUrl .= '/'; } - $oCurl = curl_init(); - curl_setopt_array($oCurl, array( - CURLOPT_URL => $sUrl.'?ExternalSso', - CURLOPT_HEADER => false, - CURLOPT_FAILONERROR => true, - CURLOPT_SSL_VERIFYPEER => false, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_POST => true, - CURLOPT_USERAGENT => 'RainLoop SSO User Agent (ownCloud)', - CURLOPT_POSTFIELDS => http_build_query(array( - 'SsoKey' => $sSsoKey, - 'Email' => $sEmail, - 'Password' => $sPassword - ), '', '&'), - CURLOPT_TIMEOUT => 5 - )); - - $mResult = curl_exec($oCurl); - if (is_resource($oCurl)) - { - curl_close($oCurl); - } - - return is_string($mResult) ? $mResult : ''; + return $sUrl; } public static function encodePassword($sPassword, $sSalt) diff --git a/build/owncloud/rainloop-app/personal.php b/build/owncloud/rainloop-app/personal.php index 36ec2c840..f995bd05f 100644 --- a/build/owncloud/rainloop-app/personal.php +++ b/build/owncloud/rainloop-app/personal.php @@ -15,9 +15,9 @@ OCP\App::checkAppEnabled('rainloop'); OCP\Util::addScript('rainloop', 'personal'); $sUrl = trim(OCP\Config::getAppValue('rainloop', 'rainloop-url', '')); -$sSsoKey = trim(OCP\Config::getAppValue('rainloop', 'rainloop-sso-key', '')); +$sPath = trim(OCP\Config::getAppValue('rainloop', 'rainloop-path', '')); -if ('' === $sUrl || '' === $sSsoKey) +if ('' === $sUrl || '' === $sPath) { $oTemplate = new OCP\Template('rainloop', 'empty'); } @@ -28,10 +28,9 @@ else $oTemplate = new OCP\Template('rainloop', 'personal'); $sEmail = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-email', ''); + $sPass = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-password', ''); $oTemplate->assign('rainloop-email', $sEmail); - - $sPass = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-password', ''); $oTemplate->assign('rainloop-password', 0 === strlen($sPass) && 0 === strlen($sEmail) ? '' : '******'); } diff --git a/build/owncloud/rainloop-app/templates/admin.php b/build/owncloud/rainloop-app/templates/admin.php index 7c0fce299..bb5492822 100644 --- a/build/owncloud/rainloop-app/templates/admin.php +++ b/build/owncloud/rainloop-app/templates/admin.php @@ -11,9 +11,9 @@

- t('SSO key')); ?>: + t('Absolute file path to RainLoop Webmail installation')); ?>:
- +

diff --git a/package.json b/package.json index 0a4f9fa9a..e3bfbd04f 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "plugins" ], "readmeFilename": "README.md", - "ownCloudPackageVersion": "1.5", + "ownCloudPackageVersion": "1.6", "engines": { "node": ">= 0.10.0" }, diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Base/Utils.php b/rainloop/v/0.0.0/app/libraries/MailSo/Base/Utils.php index 049d690ab..b870395e4 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Base/Utils.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Base/Utils.php @@ -703,6 +703,7 @@ class Utils 'sql' => 'text/plain', 'cfg' => 'text/plain', 'conf' => 'text/plain', + 'asc' => 'text/plain', 'rtx' => 'text/richtext', 'vcard' => 'text/vcard', 'vcf' => 'text/vcard', diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Cache/CacheClient.php b/rainloop/v/0.0.0/app/libraries/MailSo/Cache/CacheClient.php index 2e086f3a2..20a3993f2 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Cache/CacheClient.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Cache/CacheClient.php @@ -58,10 +58,11 @@ class CacheClient /** * @param string $sKey + * @param string $bClearAfterGet = false * * @return string */ - public function Get($sKey) + public function Get($sKey, $bClearAfterGet = false) { $sValue = ''; @@ -70,6 +71,11 @@ class CacheClient $sValue = $this->oDriver->Get($sKey.$this->sCacheIndex); } + if ($bClearAfterGet) + { + $this->Delete($sKey); + } + return $sValue; } diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php index 61a38277f..27ef272fc 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -1620,18 +1620,16 @@ class Actions $oLogger = $this->Logger(); $oLogger->Write('Trying to decode encrypted data', \MailSo\Log\Enumerations\Type::INFO, 'RSA'); - $sPrivateKey = $this->Cacher()->Get('/Key/RSA/'.$aMatch[1].'/'); + $sPrivateKey = $this->Cacher()->Get(\RainLoop\KeyPathHelper::RsaCacherKey($aMatch[1]), true); if (!empty($sPrivateKey)) { - $this->Cacher()->Delete('/Key/RSA/'.$aMatch[1].'/'); - $sData = \trim(\substr($sEncryptedData, 37)); if (!\class_exists('Crypt_RSA')) { \set_include_path(\get_include_path().PATH_SEPARATOR.APP_VERSION_ROOT_PATH.'app/libraries/phpseclib'); - include_once 'Crypt/RSA.php'; \defined('CRYPT_RSA_MODE') || \define('CRYPT_RSA_MODE', CRYPT_RSA_MODE_INTERNAL); + include_once 'Crypt/RSA.php'; } \RainLoop\Service::$__HIDE_ERROR_NOTICES = true; @@ -1677,8 +1675,8 @@ class Actions if (!\class_exists('Crypt_RSA')) { \set_include_path(\get_include_path().PATH_SEPARATOR.APP_VERSION_ROOT_PATH.'app/libraries/phpseclib'); - include_once 'Crypt/RSA.php'; \defined('CRYPT_RSA_MODE') || \define('CRYPT_RSA_MODE', CRYPT_RSA_MODE_INTERNAL); + include_once 'Crypt/RSA.php'; } $oRsa = new \Crypt_RSA(); @@ -1694,7 +1692,8 @@ class Actions \RainLoop\Service::$__HIDE_ERROR_NOTICES = false; return $this->DefaultResponse(__FUNCTION__, - $this->Cacher()->Set('/Key/RSA/'.$sHash.'/', $aKeys['privatekey']) ? array($sHash, $e->toHex(), $n->toHex()) : false); + $this->Cacher()->Set(\RainLoop\KeyPathHelper::RsaCacherKey($sHash), $aKeys['privatekey']) ? + array($sHash, $e->toHex(), $n->toHex()) : false); } } diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/KeyPathHelper.php b/rainloop/v/0.0.0/app/libraries/RainLoop/KeyPathHelper.php index 9d322d71c..e8dcab600 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/KeyPathHelper.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/KeyPathHelper.php @@ -24,6 +24,16 @@ class KeyPathHelper return '/Sso/Data/'.$sSsoHash.'/Login/'; } + /** + * @param string $sHash + * + * @return string + */ + static public function RsaCacherKey($sHash) + { + return '/Rsa/Data/'.$sHash.'/'; + } + /** * @param string $sSignMeToken *