mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Added the proper logging for #1706
This commit is contained in:
parent
ba85eda7f0
commit
28a8e3c157
6 changed files with 21 additions and 24 deletions
|
|
@ -12,6 +12,7 @@ class CustomLoginMappingPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
|
|
||||||
public function Init() : void
|
public function Init() : void
|
||||||
{
|
{
|
||||||
|
// Happens only at DoLogin | ServiceSso | DoAccountSetup
|
||||||
$this->addHook('login.credentials', 'FilterLoginCredentials');
|
$this->addHook('login.credentials', 'FilterLoginCredentials');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -29,18 +30,14 @@ class CustomLoginMappingPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
if (!empty($sMapping)) {
|
if (!empty($sMapping)) {
|
||||||
$aLines = \explode("\n", \preg_replace('/[\r\n\t\s]+/', "\n", $sMapping));
|
$aLines = \explode("\n", \preg_replace('/[\r\n\t\s]+/', "\n", $sMapping));
|
||||||
foreach ($aLines as $sLine) {
|
foreach ($aLines as $sLine) {
|
||||||
if (false !== \strpos($sLine, ':')) {
|
$aData = \explode(':', $sLine, 3);
|
||||||
$aData = \explode(':', $sLine, 3);
|
if (\is_array($aData) && isset($aData[1]) && \trim($aData[0]) === $sEmail) {
|
||||||
if (\is_array($aData) && !empty($aData[0]) && isset($aData[1])) {
|
$aData = \array_map('trim', $aData);
|
||||||
$aData = \array_map('trim', $aData);
|
if (\strlen($aData[1])) {
|
||||||
if ($sEmail === $aData[0]) {
|
$sImapUser = $aData[1];
|
||||||
if (\strlen($aData[1])) {
|
}
|
||||||
$sImapUser = $aData[1];
|
if (isset($aData[2]) && \strlen($aData[2])) {
|
||||||
}
|
$sSmtpUser = $aData[2];
|
||||||
if (isset($aData[2]) && \strlen($aData[2])) {
|
|
||||||
$sSmtpUser = $aData[2];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ trait Accounts
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Add/Edit additional account
|
||||||
* @throws \MailSo\RuntimeException
|
* @throws \MailSo\RuntimeException
|
||||||
*/
|
*/
|
||||||
public function DoAccountSetup(): array
|
public function DoAccountSetup(): array
|
||||||
|
|
|
||||||
|
|
@ -207,6 +207,7 @@ trait UserAuth
|
||||||
|
|
||||||
// Test the login
|
// Test the login
|
||||||
$oImapClient = new \MailSo\Imap\ImapClient;
|
$oImapClient = new \MailSo\Imap\ImapClient;
|
||||||
|
$oImapClient->SetLogger($this->Logger());
|
||||||
$this->imapConnect($oAccount, false, $oImapClient);
|
$this->imapConnect($oAccount, false, $oImapClient);
|
||||||
}
|
}
|
||||||
$this->SetAdditionalAuthToken($oAccount);
|
$this->SetAdditionalAuthToken($oAccount);
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,8 @@ abstract class Account implements \JsonSerializable
|
||||||
// $aAccountHash['login'] = $oDomain->ImapSettings()->fixUsername($aAccountHash['login']);
|
// $aAccountHash['login'] = $oDomain->ImapSettings()->fixUsername($aAccountHash['login']);
|
||||||
$oAccount = new static;
|
$oAccount = new static;
|
||||||
$oAccount->sEmail = \SnappyMail\IDN::emailToAscii($aAccountHash['email']);
|
$oAccount->sEmail = \SnappyMail\IDN::emailToAscii($aAccountHash['email']);
|
||||||
$oAccount->sImapUser = \SnappyMail\IDN::emailToAscii($aAccountHash['login']);
|
// $oAccount->sImapUser = \SnappyMail\IDN::emailToAscii($aAccountHash['login']);
|
||||||
|
$oAccount->sImapUser = $aAccountHash['login'];
|
||||||
$oAccount->setImapPass(new SensitiveString($aAccountHash['pass']));
|
$oAccount->setImapPass(new SensitiveString($aAccountHash['pass']));
|
||||||
$oAccount->oDomain = $oDomain;
|
$oAccount->oDomain = $oDomain;
|
||||||
$oActions->Plugins()->RunHook('filter.account', array($oAccount));
|
$oActions->Plugins()->RunHook('filter.account', array($oAccount));
|
||||||
|
|
@ -286,7 +287,7 @@ abstract class Account implements \JsonSerializable
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated since v2.36.1
|
||||||
*/
|
*/
|
||||||
public function IncLogin() : string
|
public function IncLogin() : string
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ class Domain implements \JsonSerializable
|
||||||
|
|
||||||
public function ValidateWhiteList(string $sEmail) : bool
|
public function ValidateWhiteList(string $sEmail) : bool
|
||||||
{
|
{
|
||||||
$sW = \trim($this->whiteList);
|
$sW = $this->whiteList;
|
||||||
if (!$sW) {
|
if (!$sW) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -210,7 +210,7 @@ class Domain implements \JsonSerializable
|
||||||
$oDomain->SMTP->setSender = !empty($aDomain['smtp_set_sender']);
|
$oDomain->SMTP->setSender = !empty($aDomain['smtp_set_sender']);
|
||||||
$oDomain->SMTP->usePhpMail = !empty($aDomain['smtp_php_mail']);
|
$oDomain->SMTP->usePhpMail = !empty($aDomain['smtp_php_mail']);
|
||||||
|
|
||||||
$oDomain->whiteList = \trim($aDomain['white_list'] ?? '');
|
$oDomain->whiteList = $aDomain['white_list'] ?? '';
|
||||||
|
|
||||||
$oDomain->Normalize();
|
$oDomain->Normalize();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,9 @@ use RainLoop\Exceptions\ClientException;
|
||||||
|
|
||||||
class Domain extends AbstractProvider
|
class Domain extends AbstractProvider
|
||||||
{
|
{
|
||||||
/**
|
private Domain\DomainInterface $oDriver;
|
||||||
* @var Domain\DomainInterface
|
|
||||||
*/
|
|
||||||
private $oDriver;
|
|
||||||
|
|
||||||
/**
|
private \RainLoop\Plugins\Manager $oPlugins;
|
||||||
* @var \RainLoop\Plugins\Manager
|
|
||||||
*/
|
|
||||||
private $oPlugins;
|
|
||||||
|
|
||||||
public function __construct(Domain\DomainInterface $oDriver, \RainLoop\Plugins\Manager $oPlugins)
|
public function __construct(Domain\DomainInterface $oDriver, \RainLoop\Plugins\Manager $oPlugins)
|
||||||
{
|
{
|
||||||
|
|
@ -86,10 +80,13 @@ class Domain extends AbstractProvider
|
||||||
{
|
{
|
||||||
$oDomain = $this->Load(\MailSo\Base\Utils::getEmailAddressDomain($sEmail), true);
|
$oDomain = $this->Load(\MailSo\Base\Utils::getEmailAddressDomain($sEmail), true);
|
||||||
if (!$oDomain) {
|
if (!$oDomain) {
|
||||||
|
$this->logWrite("{$sEmail} has no domain configuration", \LOG_INFO, 'domain');
|
||||||
throw new ClientException(Notifications::DomainNotAllowed);
|
throw new ClientException(Notifications::DomainNotAllowed);
|
||||||
}
|
}
|
||||||
if (!$oDomain->ValidateWhiteList($sEmail)) {
|
if (!$oDomain->ValidateWhiteList($sEmail)) {
|
||||||
|
$this->logWrite("{$sEmail} not whitelisted in {$oDomain->Name()}", \LOG_WARNING, 'domain');
|
||||||
throw new ClientException(Notifications::AccountNotAllowed);
|
throw new ClientException(Notifications::AccountNotAllowed);
|
||||||
|
// throw new ClientException(Notifications::AccountNotAllowed, null, "{$sEmail} not whitelisted in {$oDomain->Name()}");
|
||||||
}
|
}
|
||||||
return $oDomain;
|
return $oDomain;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue