mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 16:37:02 +03:00
Drop support for IMAP PROXYAUTH as it is a non-standard X-NETSCAPE thing
This commit is contained in:
parent
521f5e0d08
commit
fd54796710
8 changed files with 2 additions and 126 deletions
|
|
@ -1,20 +0,0 @@
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2014 RainLoop Team
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
||||||
this software and associated documentation files (the "Software"), to deal in
|
|
||||||
the Software without restriction, including without limitation the rights to
|
|
||||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
||||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
||||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
||||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
||||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use RainLoop\Model\MainAccount;
|
|
||||||
|
|
||||||
class ProxyauthLoginExamplePlugin extends \RainLoop\Plugins\AbstractPlugin
|
|
||||||
{
|
|
||||||
const
|
|
||||||
NAME = 'Proxy Auth Login Example',
|
|
||||||
VERSION = '2.2',
|
|
||||||
RELEASE = '2023-10-24',
|
|
||||||
REQUIRED = '2.23.0',
|
|
||||||
CATEGORY = 'General',
|
|
||||||
DESCRIPTION = '';
|
|
||||||
|
|
||||||
public function Init() : void
|
|
||||||
{
|
|
||||||
$this->addHook('login.success', 'EventLoginPostLoginProvide');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $sLogin
|
|
||||||
* @param string $sPassword
|
|
||||||
*/
|
|
||||||
public function isValidAccount($sLogin, $sPassword)
|
|
||||||
{
|
|
||||||
return !empty($sLogin) && !empty($sPassword);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \RainLoop\Model\Account $oAccount
|
|
||||||
*/
|
|
||||||
public function EventLoginPostLoginProvide(MainAccount $oAccount)
|
|
||||||
{
|
|
||||||
// Verify logic
|
|
||||||
if (!$this->isValidAccount($oAccount->IncLogin(), $oAccount->IncPassword())) {
|
|
||||||
// throw a Auth Error Exception
|
|
||||||
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AuthError);
|
|
||||||
}
|
|
||||||
|
|
||||||
$oAccount->SetProxyAuthUser('admin@domain.com');
|
|
||||||
$oAccount->SetProxyAuthPassword('secret-admin-password');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -110,17 +110,8 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($oSettings->ProxyAuthUser) && $oSettings->ProxyAuthPassword) {
|
$sLogin = \MailSo\Base\Utils::IdnToAscii(\MailSo\Base\Utils::Trim($oSettings->Login));
|
||||||
$sLogin = $oSettings->ProxyAuthUser;
|
$sPassword = $oSettings->Password;
|
||||||
$sPassword = $oSettings->ProxyAuthPassword->getValue();
|
|
||||||
$sProxyAuthUser = $oSettings->Login;
|
|
||||||
} else {
|
|
||||||
$sLogin = $oSettings->Login;
|
|
||||||
$sPassword = $oSettings->Password;
|
|
||||||
$sProxyAuthUser = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$sLogin = \MailSo\Base\Utils::IdnToAscii(\MailSo\Base\Utils::Trim($sLogin));
|
|
||||||
|
|
||||||
if (!\strlen($sLogin) || !\strlen($sPassword)) {
|
if (!\strlen($sLogin) || !\strlen($sPassword)) {
|
||||||
$this->writeLogException(new \UnexpectedValueException, \LOG_ERR);
|
$this->writeLogException(new \UnexpectedValueException, \LOG_ERR);
|
||||||
|
|
@ -221,9 +212,6 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
|
|
||||||
$this->setCapabilities($oResponse);
|
$this->setCapabilities($oResponse);
|
||||||
|
|
||||||
if (\strlen($sProxyAuthUser)) {
|
|
||||||
$this->SendRequestGetResponse('PROXYAUTH', array($this->EscapeString($sProxyAuthUser)));
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
// TODO: RFC 9051
|
// TODO: RFC 9051
|
||||||
if ($this->hasCapability('IMAP4rev2')) {
|
if ($this->hasCapability('IMAP4rev2')) {
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,6 @@ class ConnectSettings implements \JsonSerializable
|
||||||
];
|
];
|
||||||
public string $Login = '';
|
public string $Login = '';
|
||||||
private ?SensitiveString $Password = null;
|
private ?SensitiveString $Password = null;
|
||||||
public string $ProxyAuthUser = '';
|
|
||||||
public ?SensitiveString $ProxyAuthPassword = null;
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,6 @@ abstract class Account implements \JsonSerializable
|
||||||
|
|
||||||
private ?SensitiveString $sSmtpPassword = null;
|
private ?SensitiveString $sSmtpPassword = null;
|
||||||
|
|
||||||
private string $sProxyAuthUser = '';
|
|
||||||
|
|
||||||
private ?SensitiveString $sProxyAuthPassword = null;
|
|
||||||
|
|
||||||
private Domain $oDomain;
|
private Domain $oDomain;
|
||||||
|
|
||||||
public function Email() : string
|
public function Email() : string
|
||||||
|
|
@ -85,19 +81,6 @@ abstract class Account implements \JsonSerializable
|
||||||
$this->sSmtpPassword = new SensitiveString($sPassword);
|
$this->sSmtpPassword = new SensitiveString($sPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SetProxyAuthUser(string $sProxyAuthUser) : void
|
|
||||||
{
|
|
||||||
$this->sProxyAuthUser = $sProxyAuthUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function SetProxyAuthPassword(
|
|
||||||
#[\SensitiveParameter]
|
|
||||||
string $sProxyAuthPassword
|
|
||||||
) : void
|
|
||||||
{
|
|
||||||
$this->sProxyAuthPassword = new SensitiveString($sProxyAuthPassword);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[\ReturnTypeWillChange]
|
#[\ReturnTypeWillChange]
|
||||||
public function jsonSerialize()
|
public function jsonSerialize()
|
||||||
{
|
{
|
||||||
|
|
@ -113,12 +96,6 @@ abstract class Account implements \JsonSerializable
|
||||||
'pass' => $this->sSmtpPassword->getValue()
|
'pass' => $this->sSmtpPassword->getValue()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
if ($this->sProxyAuthUser && $this->sProxyAuthPassword) {
|
|
||||||
$result['proxy'] = [
|
|
||||||
'user' => $this->sProxyAuthUser,
|
|
||||||
'pass' => $this->sProxyAuthPassword->getValue()
|
|
||||||
];
|
|
||||||
}
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -204,11 +181,6 @@ abstract class Account implements \JsonSerializable
|
||||||
$oAccount->sSmtpLogin = $aAccountHash['smtp']['user'];
|
$oAccount->sSmtpLogin = $aAccountHash['smtp']['user'];
|
||||||
$oAccount->SetSmtpPassword($aAccountHash['smtp']['pass']);
|
$oAccount->SetSmtpPassword($aAccountHash['smtp']['pass']);
|
||||||
}
|
}
|
||||||
// init proxy user/password
|
|
||||||
if (isset($aAccountHash['proxy'])) {
|
|
||||||
$oAccount->sProxyAuthUser = $aAccountHash['proxy']['user'];
|
|
||||||
$oAccount->SetProxyAuthPassword($aAccountHash['proxy']['pass']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $oAccount;
|
return $oAccount;
|
||||||
|
|
@ -290,8 +262,6 @@ abstract class Account implements \JsonSerializable
|
||||||
)
|
)
|
||||||
*/
|
*/
|
||||||
$oSettings = $oClient->Settings;
|
$oSettings = $oClient->Settings;
|
||||||
$oSettings->ProxyAuthUser = $this->sProxyAuthUser;
|
|
||||||
$oSettings->ProxyAuthPassword = $this->sProxyAuthPassword;
|
|
||||||
|
|
||||||
$client_name = \strtolower($oClient->getLogName());
|
$client_name = \strtolower($oClient->getLogName());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,6 @@ class AdditionalAccount extends Account
|
||||||
if (!empty($aData['smtp']['pass'])) {
|
if (!empty($aData['smtp']['pass'])) {
|
||||||
$aData['smtp']['pass'] = \SnappyMail\Crypt::EncryptUrlSafe($aData['smtp']['pass'], $sHash);
|
$aData['smtp']['pass'] = \SnappyMail\Crypt::EncryptUrlSafe($aData['smtp']['pass'], $sHash);
|
||||||
}
|
}
|
||||||
if (!empty($aData['proxy']['pass'])) {
|
|
||||||
$aData['proxy']['pass'] = \SnappyMail\Crypt::EncryptUrlSafe($aData['proxy']['pass'], $sHash); // sProxyAuthPassword
|
|
||||||
}
|
|
||||||
$aData['hmac'] = \hash_hmac('sha1', $aData['pass'], $sHash);
|
$aData['hmac'] = \hash_hmac('sha1', $aData['pass'], $sHash);
|
||||||
return $aData;
|
return $aData;
|
||||||
}
|
}
|
||||||
|
|
@ -58,17 +55,11 @@ class AdditionalAccount extends Account
|
||||||
if (!empty($aData['smtp']['pass'])) {
|
if (!empty($aData['smtp']['pass'])) {
|
||||||
$aAccountHash['smtp']['pass'] = \SnappyMail\Crypt::DecryptUrlSafe($aAccountHash['smtp']['pass'], $sHash);
|
$aAccountHash['smtp']['pass'] = \SnappyMail\Crypt::DecryptUrlSafe($aAccountHash['smtp']['pass'], $sHash);
|
||||||
}
|
}
|
||||||
if (!empty($aData['proxy']['pass'])) {
|
|
||||||
$aAccountHash['proxy']['pass'] = \SnappyMail\Crypt::DecryptUrlSafe($aAccountHash['proxy']['pass'], $sHash);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$aAccountHash['pass'] = '';
|
$aAccountHash['pass'] = '';
|
||||||
if (!empty($aData['smtp']['pass'])) {
|
if (!empty($aData['smtp']['pass'])) {
|
||||||
$aAccountHash['smtp']['pass'] = '';
|
$aAccountHash['smtp']['pass'] = '';
|
||||||
}
|
}
|
||||||
if (!empty($aData['proxy']['pass'])) {
|
|
||||||
$aAccountHash['proxy']['pass'] = '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return parent::NewInstanceFromTokenArray($oActions, $aAccountHash, $bThrowExceptionOnFalse);
|
return parent::NewInstanceFromTokenArray($oActions, $aAccountHash, $bThrowExceptionOnFalse);
|
||||||
|
|
|
||||||
|
|
@ -93,12 +93,6 @@ abstract class Upgrade
|
||||||
'pass' => $aAccountHash[3],
|
'pass' => $aAccountHash[3],
|
||||||
'hmac' => \hash_hmac('sha1', $aAccountHash[3], $sHash)
|
'hmac' => \hash_hmac('sha1', $aAccountHash[3], $sHash)
|
||||||
];
|
];
|
||||||
if ($aAccountHash[8] && $aAccountHash[9]) {
|
|
||||||
$aNewAccounts[$sEmail]['proxy'] = [
|
|
||||||
'user' => $aAccount[5],
|
|
||||||
'pass' => $aAccount[6]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
\SnappyMail\Log::warning('UPGRADE', "ConvertInsecureAccount {$sEmail} failed");
|
\SnappyMail\Log::warning('UPGRADE', "ConvertInsecureAccount {$sEmail} failed");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -179,8 +179,6 @@ function getImapClient(int $host)
|
||||||
}
|
}
|
||||||
$ImapSettings->Login = $options["user{$host}"]; // convert to punycode?
|
$ImapSettings->Login = $options["user{$host}"]; // convert to punycode?
|
||||||
$ImapSettings->Password = $options["password{$host}"];
|
$ImapSettings->Password = $options["password{$host}"];
|
||||||
// $ImapSettings1->ProxyAuthUser = '';
|
|
||||||
// $ImapSettings1->ProxyAuthPassword = '';
|
|
||||||
$ImapSettings->useAuth = true;
|
$ImapSettings->useAuth = true;
|
||||||
|
|
||||||
$oImapClient = new \MailSo\Imap\ImapClient;
|
$oImapClient = new \MailSo\Imap\ImapClient;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue