mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 07:35:55 +08:00
Cleanup config settings and provide some info
This commit is contained in:
parent
4261bdafff
commit
4922586893
|
@ -10,7 +10,7 @@ export class AdminSettingsSecurity extends AbstractViewSettings {
|
|||
constructor() {
|
||||
super();
|
||||
|
||||
this.addSettings(['UseLocalProxyForExternalImages','VerifySslCertificate','AllowSelfSigned']);
|
||||
this.addSettings(['UseLocalProxyForExternalImages']);
|
||||
|
||||
this.weakPassword = rl.app.weakPassword;
|
||||
|
||||
|
|
|
@ -119,8 +119,6 @@ export class MailMessageView extends AbstractViewRight {
|
|||
|
||||
this.moveAction = moveAction;
|
||||
|
||||
this.allowMessageActions = SettingsCapa('MessageActions');
|
||||
|
||||
const attachmentsActions = Settings.app('attachmentsActions');
|
||||
this.attachmentsActions = ko.observableArray(arrayLength(attachmentsActions) ? attachmentsActions : []);
|
||||
|
||||
|
|
|
@ -300,7 +300,7 @@ class MailClient
|
|||
{
|
||||
$aNewMessages = array();
|
||||
|
||||
if ($iPrevUidNext && $iPrevUidNext != $iCurrentUidNext && 'INBOX' === $sFolderName && $this->oImapClient->Settings->fetch_new_messages) {
|
||||
if ($this->oImapClient->Settings->fetch_new_messages && $iPrevUidNext && $iPrevUidNext != $iCurrentUidNext && 'INBOX' === $sFolderName) {
|
||||
$this->oImapClient->FolderExamine($sFolderName);
|
||||
|
||||
$aFetchResponse = $this->oImapClient->Fetch(array(
|
||||
|
|
|
@ -21,19 +21,20 @@ class Settings extends \MailSo\Net\ConnectSettings
|
|||
|
||||
public bool $enabled = false;
|
||||
|
||||
public bool $initialAuthPlain = false;
|
||||
public bool $authPlainLiteral = false;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$oConfig = \RainLoop\API::Config();
|
||||
$this->initialAuthPlain = !!$oConfig->Get('labs', 'sieve_auth_plain_initial', true);
|
||||
$this->authPlainLiteral = !$oConfig->Get('labs', 'sieve_auth_plain_initial', true);
|
||||
}
|
||||
|
||||
public static function fromArray(array $aSettings) : self
|
||||
{
|
||||
$object = parent::fromArray($aSettings);
|
||||
$object->enabled = !empty($aSettings['enabled']);
|
||||
// $object->authPlainLiteral = !empty($aSettings['authPlainLiteral']);
|
||||
return $object;
|
||||
}
|
||||
|
||||
|
@ -44,7 +45,8 @@ class Settings extends \MailSo\Net\ConnectSettings
|
|||
parent::jsonSerialize(),
|
||||
[
|
||||
// '@Object' => 'Object/SmtpSettings',
|
||||
'enabled' => $this->enabled
|
||||
'enabled' => $this->enabled,
|
||||
// 'authPlainLiteral' => $this->authPlainLiteral
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
@ -125,11 +125,11 @@ class SieveClient extends \MailSo\Net\NetClient
|
|||
$sAuth = $SASL->authenticate($sLogin, $sPassword, $sLoginAuthKey);
|
||||
$this->oLogger && $this->oLogger->AddSecret($sAuth);
|
||||
|
||||
if ($oSettings->initialAuthPlain) {
|
||||
$this->sendRaw("AUTHENTICATE \"{$type}\" \"{$sAuth}\"");
|
||||
} else {
|
||||
if ($oSettings->authPlainLiteral) {
|
||||
$this->sendRaw("AUTHENTICATE \"{$type}\" {".\strlen($sAuth).'+}');
|
||||
$this->sendRaw($sAuth);
|
||||
} else {
|
||||
$this->sendRaw("AUTHENTICATE \"{$type}\" \"{$sAuth}\"");
|
||||
}
|
||||
|
||||
$aResponse = $this->parseResponse();
|
||||
|
|
|
@ -22,17 +22,26 @@ class Settings extends \MailSo\Net\ConnectSettings
|
|||
$timeout = 60;
|
||||
|
||||
public bool
|
||||
$setSender = false,
|
||||
$usePhpMail = false,
|
||||
$setSender = false;
|
||||
$viewErrors = false;
|
||||
|
||||
public string $Ehlo;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$oConfig = \RainLoop\API::Config();
|
||||
$this->viewErrors = !!$oConfig->Get('labs', 'smtp_show_server_errors', false);
|
||||
}
|
||||
|
||||
public static function fromArray(array $aSettings) : self
|
||||
{
|
||||
$object = parent::fromArray($aSettings);
|
||||
$object->useAuth = !empty($aSettings['useAuth']);
|
||||
$object->setSender = !empty($aSettings['setSender']);
|
||||
$object->usePhpMail = !empty($aSettings['usePhpMail']);
|
||||
// $object->viewErrors = !empty($aSettings['viewErrors']);
|
||||
return $object;
|
||||
}
|
||||
|
||||
|
@ -46,6 +55,7 @@ class Settings extends \MailSo\Net\ConnectSettings
|
|||
'useAuth' => $this->useAuth,
|
||||
'setSender' => $this->setSender,
|
||||
'usePhpMail' => $this->usePhpMail
|
||||
// 'viewErrors' => $this->viewErrors
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
@ -614,7 +614,7 @@ class Actions
|
|||
'System' => \array_merge(
|
||||
array(
|
||||
'version' => APP_VERSION,
|
||||
'token' => $oConfig->Get('security', 'csrf_protection', false) ? Utils::GetCsrfToken() : '',
|
||||
'token' => $oConfig->Get('security', 'csrf_protection', true) ? Utils::GetCsrfToken() : '',
|
||||
'languages' => \SnappyMail\L10n::getLanguages(false),
|
||||
'webPath' => \RainLoop\Utils::WebPath(),
|
||||
'webVersionPath' => \RainLoop\Utils::WebVersionPath()
|
||||
|
@ -635,16 +635,12 @@ class Actions
|
|||
if ($aResult['Auth']) {
|
||||
$aResult['AdminLogin'] = (string)$oConfig->Get('security', 'admin_login', '');
|
||||
$aResult['AdminTOTP'] = (string)$oConfig->Get('security', 'admin_totp', '');
|
||||
$aResult['UseTokenProtection'] = (bool)$oConfig->Get('security', 'csrf_protection', true);
|
||||
$aResult['EnabledPlugins'] = (bool)$oConfig->Get('plugins', 'enable', false);
|
||||
|
||||
$aResult['LoginDefaultDomain'] = $oConfig->Get('login', 'default_domain', '');
|
||||
$aResult['DetermineUserLanguage'] = (bool)$oConfig->Get('login', 'determine_user_language', true);
|
||||
$aResult['DetermineUserDomain'] = (bool)$oConfig->Get('login', 'determine_user_domain', false);
|
||||
|
||||
$aResult['VerifySslCertificate'] = (bool)$oConfig->Get('ssl', 'verify_certificate', false);
|
||||
$aResult['AllowSelfSigned'] = (bool)$oConfig->Get('ssl', 'allow_self_signed', true);
|
||||
|
||||
$aResult['supportedPdoDrivers'] = \RainLoop\Common\PdoAbstract::getAvailableDrivers();
|
||||
|
||||
$aResult['ContactsEnable'] = (bool)$oConfig->Get('contacts', 'enable', false);
|
||||
|
@ -835,7 +831,7 @@ class Actions
|
|||
$sLanguage = $this->ValidateLanguage($UserLanguageRaw, $sLanguage, false);
|
||||
}
|
||||
|
||||
if ('0.0.0' === APP_VERSION) {
|
||||
if (SNAPPYMAIL_DEV) {
|
||||
$aResult['DevEmail'] = $oConfig->Get('labs', 'dev_email', '');
|
||||
$aResult['DevPassword'] = $oConfig->Get('labs', 'dev_password', '');
|
||||
} else {
|
||||
|
@ -1048,7 +1044,6 @@ class Actions
|
|||
'GnuPG' => (bool) $oConfig->Get('security', 'openpgp', false) && \SnappyMail\PGP\GnuPG::isSupported(),
|
||||
'Identities' => (bool) $oConfig->Get('webmail', 'allow_additional_identities', false),
|
||||
'Kolab' => false, // See Kolab plugin
|
||||
'MessageActions' => (bool) $oConfig->Get('capa', 'message_actions', true),
|
||||
'OpenPGP' => (bool) $oConfig->Get('security', 'openpgp', false),
|
||||
'Quota' => (bool) $oConfig->Get('capa', 'quota', true),
|
||||
'Sieve' => false,
|
||||
|
|
|
@ -7,8 +7,6 @@ use RainLoop\KeyPathHelper;
|
|||
use RainLoop\Notifications;
|
||||
use RainLoop\Utils;
|
||||
|
||||
//define('APP_DEV_VERSION', '0.0.0');
|
||||
|
||||
trait Admin
|
||||
{
|
||||
protected static string $AUTH_ADMIN_TOKEN_KEY = 'smadmin';
|
||||
|
|
|
@ -752,6 +752,7 @@ trait Messages
|
|||
|
||||
$this->Plugins()->RunHook('filter.message-rcpt', array($oAccount, $oRcpt));
|
||||
|
||||
$oSmtpClient = null;
|
||||
try
|
||||
{
|
||||
$oFrom = $oMessage->GetFrom();
|
||||
|
@ -838,7 +839,7 @@ trait Messages
|
|||
}
|
||||
catch (\MailSo\Net\Exceptions\ConnectionException $oException)
|
||||
{
|
||||
if ($this->Config()->Get('labs', 'smtp_show_server_errors')) {
|
||||
if ($oSmtpClient && $oSmtpClient->Settings->viewErrors) {
|
||||
throw new ClientException(Notifications::ClientViewError, $oException);
|
||||
}
|
||||
throw new ClientException(Notifications::ConnectionError, $oException);
|
||||
|
@ -849,7 +850,7 @@ trait Messages
|
|||
}
|
||||
catch (\Throwable $oException)
|
||||
{
|
||||
if ($this->Config()->Get('labs', 'smtp_show_server_errors')) {
|
||||
if ($oSmtpClient && $oSmtpClient->Settings->viewErrors) {
|
||||
throw new ClientException(Notifications::ClientViewError, $oException);
|
||||
}
|
||||
throw $oException;
|
||||
|
|
|
@ -116,7 +116,7 @@ trait Response
|
|||
|
||||
$oAccount = $this->getAccountFromToken();
|
||||
|
||||
if (!$mResult['DateTimeStampInUTC'] || $this->Config()->Get('labs', 'date_from_headers', false)) {
|
||||
if (!$mResult['DateTimeStampInUTC'] || $this->Config()->Get('labs', 'date_from_headers', true)) {
|
||||
$iDateTimeStampInUTC = $mResponse->HeaderTimeStampInUTC;
|
||||
if ($iDateTimeStampInUTC) {
|
||||
$mResult['DateTimeStampInUTC'] = $iDateTimeStampInUTC;
|
||||
|
|
|
@ -60,9 +60,6 @@ class ActionsAdmin extends Actions
|
|||
return $self->ValidateTheme($sTheme);
|
||||
});
|
||||
|
||||
$this->setConfigFromParams($oConfig, 'VerifySslCertificate', 'ssl', 'verify_certificate', 'bool');
|
||||
$this->setConfigFromParams($oConfig, 'AllowSelfSigned', 'ssl', 'allow_self_signed', 'bool');
|
||||
|
||||
$this->setConfigFromParams($oConfig, 'UseLocalProxyForExternalImages', 'labs', 'use_local_proxy_for_external_images', 'bool');
|
||||
|
||||
$this->setConfigFromParams($oConfig, 'AllowLanguagesOnSettings', 'webmail', 'allow_languages_on_settings', 'bool');
|
||||
|
@ -95,7 +92,6 @@ class ActionsAdmin extends Actions
|
|||
$this->setConfigFromParams($oConfig, 'LoadingDescription', 'webmail', 'loading_description', 'string');
|
||||
$this->setConfigFromParams($oConfig, 'FaviconUrl', 'webmail', 'favicon_url', 'string');
|
||||
|
||||
$this->setConfigFromParams($oConfig, 'TokenProtection', 'security', 'csrf_protection', 'bool');
|
||||
$this->setConfigFromParams($oConfig, 'EnabledPlugins', 'plugins', 'enable', 'bool');
|
||||
|
||||
return $this->DefaultResponse($oConfig->Save());
|
||||
|
@ -262,7 +258,7 @@ class ActionsAdmin extends Actions
|
|||
$sVersion = empty($info->version) ? '' : $info->version;
|
||||
|
||||
$bShowWarning = false;
|
||||
if (!empty($info->warnings) && APP_VERSION !== APP_DEV_VERSION) {
|
||||
if (!empty($info->warnings) && !SNAPPYMAIL_DEV) {
|
||||
foreach ($info->warnings as $sWarningVersion) {
|
||||
$sWarningVersion = \trim($sWarningVersion);
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ abstract class Api
|
|||
$oConfig = static::Config();
|
||||
$CSP = new \SnappyMail\HTTP\CSP(\trim($oConfig->Get('security', 'content_security_policy', '')));
|
||||
$CSP->report = $oConfig->Get('security', 'csp_report', false);
|
||||
$CSP->report_only = $oConfig->Get('debug', 'enable', false); // '0.0.0' === APP_VERSION
|
||||
$CSP->report_only = $oConfig->Get('debug', 'enable', false); // || SNAPPYMAIL_DEV
|
||||
// $CSP->frame = \explode(' ', $oConfig->Get('security', 'csp_frame', ''));
|
||||
|
||||
// Allow https: due to remote images in e-mails or use proxy
|
||||
|
|
|
@ -191,13 +191,14 @@ class Application extends \RainLoop\Config\AbstractConfig
|
|||
|
||||
'openpgp' => array(false),
|
||||
|
||||
'allow_admin_panel' => array(true, 'Access settings'),
|
||||
'admin_login' => array('admin', 'Login and password for web admin panel'),
|
||||
'admin_password' => array(''),
|
||||
'admin_totp' => array(''),
|
||||
'allow_admin_panel' => array(true, 'Access settings'),
|
||||
'hide_x_mailer_header' => array(true),
|
||||
'admin_panel_host' => array(''),
|
||||
'admin_panel_key' => array('admin'),
|
||||
|
||||
'hide_x_mailer_header' => array(true),
|
||||
'content_security_policy' => array('', 'For example to allow all images use "img-src https:". More info at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy#directives'),
|
||||
'csp_report' => array(false, 'Report CSP errors to PHP and/or SnappyMail Log'),
|
||||
'encrypt_cipher' => array('aes-256-cbc-hmac-sha1', 'A valid cipher method from https://php.net/openssl_get_cipher_methods'),
|
||||
|
@ -236,9 +237,8 @@ Default is "site=same-origin;site=none"')
|
|||
|
||||
'capa' => array(
|
||||
'quota' => array(true),
|
||||
'dangerous_actions' => array(true),
|
||||
'message_actions' => array(true),
|
||||
'attachments_actions' => array(true)
|
||||
'dangerous_actions' => array(true, 'Allow clear folder and delete messages without moving to trash'),
|
||||
'attachments_actions' => array(true, 'Allow download attachments as Zip (and optionally others)')
|
||||
),
|
||||
|
||||
'login' => array(
|
||||
|
@ -253,8 +253,8 @@ When this value is gethostname, the gethostname() value is used.
|
|||
'allow_languages_on_login' => array(true,
|
||||
'Allow language selection on webmail login screen'),
|
||||
|
||||
'determine_user_language' => array(true),
|
||||
'determine_user_domain' => array(false),
|
||||
'determine_user_language' => array(true, 'Detect language from browser header `Accept-Language`'),
|
||||
'determine_user_domain' => array(false, 'Like default_domain but then HTTP_HOST/SERVER_NAME without www.'),
|
||||
|
||||
'login_lowercase' => array(true),
|
||||
|
||||
|
@ -380,13 +380,12 @@ Enables caching in the system'),
|
|||
|
||||
'labs' => array(
|
||||
'cache_system_data' => array(true),
|
||||
'date_from_headers' => array(true),
|
||||
'date_from_headers' => array(true, 'Display message RFC 2822 date and time header, instead of the arrival internal date.'),
|
||||
'allow_message_append' => array(false),
|
||||
'login_fault_delay' => array(1),
|
||||
'log_ajax_response_write_limit' => array(300),
|
||||
'allow_html_editor_biti_buttons' => array(false),
|
||||
'allow_ctrl_enter_on_compose' => array(true),
|
||||
'try_to_detect_hidden_images' => array(false),
|
||||
'smtp_show_server_errors' => array(false),
|
||||
'sieve_auth_plain_initial' => array(true),
|
||||
'sieve_allow_fileinto_inbox' => array(false),
|
||||
|
|
|
@ -14,7 +14,6 @@ class Capa
|
|||
const IDENTITIES = 'Identities';
|
||||
const CONTACTS = 'Contacts';
|
||||
const QUOTA = 'Quota';
|
||||
const MESSAGE_ACTIONS = 'MessageActions';
|
||||
const ATTACHMENTS_ACTIONS = 'AttachmentsActions';
|
||||
const DANGEROUS_ACTIONS = 'DangerousActions';
|
||||
const AUTOLOGOUT = ''; // Obsolete
|
||||
|
|
|
@ -93,7 +93,7 @@ class ServiceActions
|
|||
}
|
||||
|
||||
if ($this->oHttp->IsPost() &&
|
||||
$this->Config()->Get('security', 'csrf_protection', false) &&
|
||||
$this->Config()->Get('security', 'csrf_protection', true) &&
|
||||
($_POST['XToken'] ?? '') !== Utils::GetCsrfToken())
|
||||
{
|
||||
throw new Exceptions\ClientException(Notifications::InvalidToken, null, 'CSRF failed');
|
||||
|
|
|
@ -112,7 +112,6 @@ abstract class Repository
|
|||
{
|
||||
$aResult = array();
|
||||
try {
|
||||
$isDev = '0.0.0' === APP_VERSION;
|
||||
foreach (static::getRepositoryDataByUrl($bReal) as $oItem) {
|
||||
if ($oItem
|
||||
&& isset($oItem->type, $oItem->id, $oItem->name, $oItem->version, $oItem->release, $oItem->file, $oItem->description)
|
||||
|
@ -120,9 +119,9 @@ abstract class Repository
|
|||
// is this entry newer then an already defined one
|
||||
&& (empty($aResult[$oItem->id]) || \version_compare($aResult[$oItem->id]['version'], $oItem->version, '<'))
|
||||
// does this entry require same or older app version
|
||||
&& ($isDev || empty($oItem->required) || \version_compare(APP_VERSION, $oItem->required, '>='))
|
||||
&& (SNAPPYMAIL_DEV || empty($oItem->required) || \version_compare(APP_VERSION, $oItem->required, '>='))
|
||||
// is this entry not deprecated for current app version?
|
||||
&& ($isDev || empty($oItem->deprecated) || \version_compare(APP_VERSION, $oItem->deprecated, '<'))
|
||||
&& (SNAPPYMAIL_DEV || empty($oItem->deprecated) || \version_compare(APP_VERSION, $oItem->deprecated, '<'))
|
||||
) {
|
||||
$aResult[$oItem->id] = array(
|
||||
'type' => $oItem->type,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<div class="legend">application.ini</div>
|
||||
<p><strong>WARNING: experimental editor!</strong></p>
|
||||
<form method="POST" data-bind="submit: saveConfig" spellcheck="false" autocomplete="off" autocapitalize="none">
|
||||
<table class="table table-hover table-bordered">
|
||||
<!-- ko foreach: config -->
|
||||
|
|
|
@ -56,25 +56,3 @@
|
|||
data-icon="🔑" data-i18n="GLOBAL/SAVE"></a>
|
||||
</div>
|
||||
</form>
|
||||
<div class="form-horizontal">
|
||||
<div class="legend">SSL/TLS</div>
|
||||
<div class="control-group">
|
||||
<div>
|
||||
<div data-bind="component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
value: verifySslCertificate,
|
||||
label: 'TAB_SECURITY/LABEL_REQUIRE_VERIFICATION'
|
||||
}
|
||||
}"></div>
|
||||
<div data-bind="component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
enable: verifySslCertificate,
|
||||
value: allowSelfSigned,
|
||||
label: 'TAB_SECURITY/LABEL_ALLOW_SELF_SIGNED'
|
||||
}
|
||||
}"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
<a target="_blank" href="#" tabindex="-1" data-bind="attr: { href: firstUnsubsribeLink }" data-icon="✖" data-i18n="MESSAGE/BUTTON_UNSUBSCRIBE"></a>
|
||||
</li>
|
||||
</div>
|
||||
<div data-bind="visible: allowMessageActions, with: message" class="dividerbar">
|
||||
<div data-bind="with: message" class="dividerbar">
|
||||
<li role="presentation">
|
||||
<a href="#" tabindex="-1" data-bind="click: printMessage" data-icon="🖨" data-i18n="MESSAGE/MENU_PRINT"></a>
|
||||
</li>
|
||||
|
|
|
@ -37,6 +37,9 @@ if (!function_exists('str_ends_with')) {
|
|||
if (!defined('APP_VERSION')) {
|
||||
define('APP_VERSION', basename(__DIR__));
|
||||
}
|
||||
if (!defined('SNAPPYMAIL_DEV')) {
|
||||
define('SNAPPYMAIL_DEV', '0.0.0' === APP_VERSION);
|
||||
}
|
||||
|
||||
if (!defined('APP_INDEX_ROOT_PATH')) {
|
||||
define('APP_INDEX_ROOT_PATH', dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR);
|
||||
|
|
Loading…
Reference in a new issue