1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Remove all legacy configuration options for mailers

Summary:
Ref T920. About a year ago (in 2018 Week 6, see D19003) we moved from individually configured mailers to `cluster.mailers`, primarily to support fallback across multiple mail providers.

Since this has been stable for quite a while, drop support for the older options.

Test Plan: Grepped for all removed options.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T920

Differential Revision: https://secure.phabricator.com/D19940
This commit is contained in:
epriestley 2019-01-01 20:11:07 -08:00
parent cfcd35d8a3
commit 9d5b933ed5
19 changed files with 51 additions and 387 deletions

View file

@ -3405,10 +3405,8 @@ phutil_register_library_map(array(
'PhabricatorMailReceiverTestCase' => 'applications/metamta/receiver/__tests__/PhabricatorMailReceiverTestCase.php',
'PhabricatorMailReplyHandler' => 'applications/metamta/replyhandler/PhabricatorMailReplyHandler.php',
'PhabricatorMailRoutingRule' => 'applications/metamta/constants/PhabricatorMailRoutingRule.php',
'PhabricatorMailSetupCheck' => 'applications/config/check/PhabricatorMailSetupCheck.php',
'PhabricatorMailStamp' => 'applications/metamta/stamp/PhabricatorMailStamp.php',
'PhabricatorMailTarget' => 'applications/metamta/replyhandler/PhabricatorMailTarget.php',
'PhabricatorMailgunConfigOptions' => 'applications/config/option/PhabricatorMailgunConfigOptions.php',
'PhabricatorMainMenuBarExtension' => 'view/page/menu/PhabricatorMainMenuBarExtension.php',
'PhabricatorMainMenuSearchView' => 'view/page/menu/PhabricatorMainMenuSearchView.php',
'PhabricatorMainMenuView' => 'view/page/menu/PhabricatorMainMenuView.php',
@ -3657,7 +3655,6 @@ phutil_register_library_map(array(
'PhabricatorPHIDsSearchField' => 'applications/search/field/PhabricatorPHIDsSearchField.php',
'PhabricatorPHPASTApplication' => 'applications/phpast/application/PhabricatorPHPASTApplication.php',
'PhabricatorPHPConfigSetupCheck' => 'applications/config/check/PhabricatorPHPConfigSetupCheck.php',
'PhabricatorPHPMailerConfigOptions' => 'applications/config/option/PhabricatorPHPMailerConfigOptions.php',
'PhabricatorPHPPreflightSetupCheck' => 'applications/config/check/PhabricatorPHPPreflightSetupCheck.php',
'PhabricatorPackagesApplication' => 'applications/packages/application/PhabricatorPackagesApplication.php',
'PhabricatorPackagesController' => 'applications/packages/controller/PhabricatorPackagesController.php',
@ -4312,7 +4309,6 @@ phutil_register_library_map(array(
'PhabricatorSecuritySetupCheck' => 'applications/config/check/PhabricatorSecuritySetupCheck.php',
'PhabricatorSelectEditField' => 'applications/transactions/editfield/PhabricatorSelectEditField.php',
'PhabricatorSelectSetting' => 'applications/settings/setting/PhabricatorSelectSetting.php',
'PhabricatorSendGridConfigOptions' => 'applications/config/option/PhabricatorSendGridConfigOptions.php',
'PhabricatorSessionsSettingsPanel' => 'applications/settings/panel/PhabricatorSessionsSettingsPanel.php',
'PhabricatorSetConfigType' => 'applications/config/type/PhabricatorSetConfigType.php',
'PhabricatorSetting' => 'applications/settings/setting/PhabricatorSetting.php',
@ -9214,10 +9210,8 @@ phutil_register_library_map(array(
'PhabricatorMailReceiverTestCase' => 'PhabricatorTestCase',
'PhabricatorMailReplyHandler' => 'Phobject',
'PhabricatorMailRoutingRule' => 'Phobject',
'PhabricatorMailSetupCheck' => 'PhabricatorSetupCheck',
'PhabricatorMailStamp' => 'Phobject',
'PhabricatorMailTarget' => 'Phobject',
'PhabricatorMailgunConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorMainMenuBarExtension' => 'Phobject',
'PhabricatorMainMenuSearchView' => 'AphrontView',
'PhabricatorMainMenuView' => 'AphrontView',
@ -9509,7 +9503,6 @@ phutil_register_library_map(array(
'PhabricatorPHIDsSearchField' => 'PhabricatorSearchField',
'PhabricatorPHPASTApplication' => 'PhabricatorApplication',
'PhabricatorPHPConfigSetupCheck' => 'PhabricatorSetupCheck',
'PhabricatorPHPMailerConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorPHPPreflightSetupCheck' => 'PhabricatorSetupCheck',
'PhabricatorPackagesApplication' => 'PhabricatorApplication',
'PhabricatorPackagesController' => 'PhabricatorController',
@ -10331,7 +10324,6 @@ phutil_register_library_map(array(
'PhabricatorSecuritySetupCheck' => 'PhabricatorSetupCheck',
'PhabricatorSelectEditField' => 'PhabricatorEditField',
'PhabricatorSelectSetting' => 'PhabricatorSetting',
'PhabricatorSendGridConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorSessionsSettingsPanel' => 'PhabricatorSettingsPanel',
'PhabricatorSetConfigType' => 'PhabricatorTextConfigType',
'PhabricatorSetting' => 'Phobject',

View file

@ -200,6 +200,9 @@ final class PhabricatorExtraConfigSetupCheck extends PhabricatorSetupCheck {
'Elasticsearch is now configured with "%s".',
'cluster.search');
$mailers_reason = pht(
'Inbound and outbound mail is now configured with "cluster.mailers".');
$ancient_config += array(
'phid.external-loaders' =>
pht(
@ -354,6 +357,21 @@ final class PhabricatorExtraConfigSetupCheck extends PhabricatorSetupCheck {
'search.elastic.host' => $elastic_reason,
'search.elastic.namespace' => $elastic_reason,
'metamta.mail-adapter' => $mailers_reason,
'amazon-ses.access-key' => $mailers_reason,
'amazon-ses.secret-key' => $mailers_reason,
'amazon-ses.endpoint' => $mailers_reason,
'mailgun.domain' => $mailers_reason,
'mailgun.api-key' => $mailers_reason,
'phpmailer.mailer' => $mailers_reason,
'phpmailer.smtp-host' => $mailers_reason,
'phpmailer.smtp-port' => $mailers_reason,
'phpmailer.smtp-protocol' => $mailers_reason,
'phpmailer.smtp-user' => $mailers_reason,
'phpmailer.smtp-password' => $mailers_reason,
'phpmailer.smtp-encoding' => $mailers_reason,
'sendgrid.api-user' => $mailers_reason,
'sendgrid.api-key' => $mailers_reason,
);
return $ancient_config;

View file

@ -1,104 +0,0 @@
<?php
final class PhabricatorMailSetupCheck extends PhabricatorSetupCheck {
public function getDefaultGroup() {
return self::GROUP_OTHER;
}
protected function executeChecks() {
if (PhabricatorEnv::getEnvConfig('cluster.mailers')) {
return;
}
$adapter = PhabricatorEnv::getEnvConfig('metamta.mail-adapter');
switch ($adapter) {
case 'PhabricatorMailImplementationPHPMailerLiteAdapter':
if (!Filesystem::pathExists('/usr/bin/sendmail') &&
!Filesystem::pathExists('/usr/sbin/sendmail')) {
$message = pht(
'Mail is configured to send via sendmail, but this system has '.
'no sendmail binary. Install sendmail or choose a different '.
'mail adapter.');
$this->newIssue('config.metamta.mail-adapter')
->setShortName(pht('Missing Sendmail'))
->setName(pht('No Sendmail Binary Found'))
->setMessage($message)
->addRelatedPhabricatorConfig('metamta.mail-adapter');
}
break;
case 'PhabricatorMailImplementationAmazonSESAdapter':
if (PhabricatorEnv::getEnvConfig('metamta.can-send-as-user')) {
$message = pht(
'Amazon SES does not support sending email as users. Disable '.
'send as user, or choose a different mail adapter.');
$this->newIssue('config.can-send-as-user')
->setName(pht("SES Can't Send As User"))
->setMessage($message)
->addRelatedPhabricatorConfig('metamta.mail-adapter')
->addPhabricatorConfig('metamta.can-send-as-user');
}
if (!PhabricatorEnv::getEnvConfig('amazon-ses.access-key')) {
$message = pht(
'Amazon SES is selected as the mail adapter, but no SES access '.
'key is configured. Provide an SES access key, or choose a '.
'different mail adapter.');
$this->newIssue('config.amazon-ses.access-key')
->setName(pht('Amazon SES Access Key Not Set'))
->setMessage($message)
->addRelatedPhabricatorConfig('metamta.mail-adapter')
->addPhabricatorConfig('amazon-ses.access-key');
}
if (!PhabricatorEnv::getEnvConfig('amazon-ses.secret-key')) {
$message = pht(
'Amazon SES is selected as the mail adapter, but no SES secret '.
'key is configured. Provide an SES secret key, or choose a '.
'different mail adapter.');
$this->newIssue('config.amazon-ses.secret-key')
->setName(pht('Amazon SES Secret Key Not Set'))
->setMessage($message)
->addRelatedPhabricatorConfig('metamta.mail-adapter')
->addPhabricatorConfig('amazon-ses.secret-key');
}
if (!PhabricatorEnv::getEnvConfig('amazon-ses.endpoint')) {
$message = pht(
'Amazon SES is selected as the mail adapter, but no SES endpoint '.
'is configured. Provide an SES endpoint or choose a different '.
'mail adapter.');
$this->newIssue('config.amazon-ses.endpoint')
->setName(pht('Amazon SES Endpoint Not Set'))
->setMessage($message)
->addRelatedPhabricatorConfig('metamta.mail-adapter')
->addPhabricatorConfig('amazon-ses.endpoint');
}
$address_key = 'metamta.default-address';
$options = PhabricatorApplicationConfigOptions::loadAllOptions();
$default = $options[$address_key]->getDefault();
$value = PhabricatorEnv::getEnvConfig($address_key);
if ($default === $value) {
$message = pht(
'Amazon SES requires verification of the "From" address, but '.
'you have not configured a "From" address. Configure and verify '.
'a "From" address, or choose a different mail adapter.');
$this->newIssue('config.metamta.default-address')
->setName(pht('No SES From Address Configured'))
->setMessage($message)
->addRelatedPhabricatorConfig('metamta.mail-adapter')
->addPhabricatorConfig('metamta.default-address');
}
break;
}
}
}

View file

@ -21,24 +21,6 @@ final class PhabricatorAWSConfigOptions
public function getOptions() {
return array(
$this->newOption('amazon-ses.access-key', 'string', null)
->setLocked(true)
->setDescription(pht('Access key for Amazon SES.')),
$this->newOption('amazon-ses.secret-key', 'string', null)
->setHidden(true)
->setDescription(pht('Secret key for Amazon SES.')),
$this->newOption('amazon-ses.endpoint', 'string', null)
->setLocked(true)
->setDescription(
pht(
'SES endpoint domain name. You can find a list of available '.
'regions and endpoints in the AWS documentation.'))
->addExample(
'email.us-east-1.amazonaws.com',
pht('US East (N. Virginia, Older default endpoint)'))
->addExample(
'email.us-west-2.amazonaws.com',
pht('US West (Oregon)')),
$this->newOption('amazon-s3.access-key', 'string', null)
->setLocked(true)
->setDescription(pht('Access key for Amazon S3.')),

View file

@ -1,38 +0,0 @@
<?php
final class PhabricatorMailgunConfigOptions
extends PhabricatorApplicationConfigOptions {
public function getName() {
return pht('Integration with Mailgun');
}
public function getDescription() {
return pht('Configure Mailgun integration.');
}
public function getIcon() {
return 'fa-send-o';
}
public function getGroup() {
return 'core';
}
public function getOptions() {
return array(
$this->newOption('mailgun.domain', 'string', null)
->setLocked(true)
->setDescription(
pht(
'Mailgun domain name. See %s.',
'https://mailgun.com/cp/domains'))
->addExample('mycompany.com', pht('Use specific domain')),
$this->newOption('mailgun.api-key', 'string', null)
->setHidden(true)
->setDescription(pht('Mailgun API key.')),
);
}
}

View file

@ -208,13 +208,6 @@ EODOC
'string',
'phabricator.example.com')
->setDescription(pht('Domain used to generate Message-IDs.')),
$this->newOption(
'metamta.mail-adapter',
'class',
'PhabricatorMailImplementationPHPMailerLiteAdapter')
->setBaseClass('PhabricatorMailImplementationAdapter')
->setSummary(pht('Control how mail is sent.'))
->setDescription($adapter_description),
$this->newOption(
'metamta.one-mail-per-recipient',
'bool',

View file

@ -1,72 +0,0 @@
<?php
final class PhabricatorPHPMailerConfigOptions
extends PhabricatorApplicationConfigOptions {
public function getName() {
return pht('PHPMailer');
}
public function getDescription() {
return pht('Configure PHPMailer.');
}
public function getIcon() {
return 'fa-send-o';
}
public function getGroup() {
return 'core';
}
public function getOptions() {
return array(
$this->newOption('phpmailer.mailer', 'string', 'smtp')
->setLocked(true)
->setSummary(pht('Configure mailer used by PHPMailer.'))
->setDescription(
pht(
"If you're using PHPMailer to send email, provide the mailer and ".
"options here. PHPMailer is much more enormous than ".
"PHPMailerLite, and provides more mailers and greater enormity. ".
"You need it when you want to use SMTP instead of sendmail as the ".
"mailer.")),
$this->newOption('phpmailer.smtp-host', 'string', null)
->setLocked(true)
->setDescription(pht('Host for SMTP.')),
$this->newOption('phpmailer.smtp-port', 'int', 25)
->setLocked(true)
->setDescription(pht('Port for SMTP.')),
// TODO: Implement "enum"? Valid values are empty, 'tls', or 'ssl'.
$this->newOption('phpmailer.smtp-protocol', 'string', null)
->setLocked(true)
->setSummary(pht('Configure TLS or SSL for SMTP.'))
->setDescription(
pht(
"Using PHPMailer with SMTP, you can set this to one of '%s' or ".
"'%s' to use TLS or SSL, respectively. Leave it blank for ".
"vanilla SMTP. If you're sending via Gmail, set it to '%s'.",
'tls',
'ssl',
'ssl')),
$this->newOption('phpmailer.smtp-user', 'string', null)
->setLocked(true)
->setDescription(pht('Username for SMTP.')),
$this->newOption('phpmailer.smtp-password', 'string', null)
->setHidden(true)
->setDescription(pht('Password for SMTP.')),
$this->newOption('phpmailer.smtp-encoding', 'string', 'base64')
->setSummary(pht('Configure how mail is encoded.'))
->setDescription(
pht(
"Mail is normally encoded in `8bit`, which works correctly with ".
"most MTAs. However, some MTAs do not work well with this ".
"encoding. If you're having trouble with mail being mangled or ".
"arriving with too many or too few newlines, you may try ".
"adjusting this setting.\n\n".
"Supported values are `8bit`, `quoted-printable`, ".
"`7bit`, `binary` and `base64`.")),
);
}
}

View file

@ -1,33 +0,0 @@
<?php
final class PhabricatorSendGridConfigOptions
extends PhabricatorApplicationConfigOptions {
public function getName() {
return pht('Integration with SendGrid');
}
public function getDescription() {
return pht('Configure SendGrid integration.');
}
public function getIcon() {
return 'fa-send-o';
}
public function getGroup() {
return 'core';
}
public function getOptions() {
return array(
$this->newOption('sendgrid.api-user', 'string', null)
->setLocked(true)
->setDescription(pht('SendGrid API username.')),
$this->newOption('sendgrid.api-key', 'string', null)
->setHidden(true)
->setDescription(pht('SendGrid API key.')),
);
}
}

View file

@ -109,7 +109,6 @@ abstract class PhabricatorMailImplementationAdapter extends Phobject {
abstract protected function validateOptions(array $options);
abstract public function newDefaultOptions();
abstract public function newLegacyOptions();
public function prepareForSend() {
return;

View file

@ -39,15 +39,6 @@ final class PhabricatorMailImplementationAmazonSESAdapter
);
}
public function newLegacyOptions() {
return array(
'access-key' => PhabricatorEnv::getEnvConfig('amazon-ses.access-key'),
'secret-key' => PhabricatorEnv::getEnvConfig('amazon-ses.secret-key'),
'endpoint' => PhabricatorEnv::getEnvConfig('amazon-ses.endpoint'),
'encoding' => PhabricatorEnv::getEnvConfig('phpmailer.smtp-encoding'),
);
}
/**
* @phutil-external-symbol class SimpleEmailService
*/

View file

@ -89,13 +89,6 @@ final class PhabricatorMailImplementationMailgunAdapter
);
}
public function newLegacyOptions() {
return array(
'api-key' => PhabricatorEnv::getEnvConfig('mailgun.api-key'),
'domain' => PhabricatorEnv::getEnvConfig('mailgun.domain'),
);
}
public function send() {
$key = $this->getOption('api-key');
$domain = $this->getOption('domain');

View file

@ -33,18 +33,6 @@ final class PhabricatorMailImplementationPHPMailerAdapter
);
}
public function newLegacyOptions() {
return array(
'host' => PhabricatorEnv::getEnvConfig('phpmailer.smtp-host'),
'port' => PhabricatorEnv::getEnvConfig('phpmailer.smtp-port'),
'user' => PhabricatorEnv::getEnvConfig('phpmailer.smtp-user'),
'password' => PhabricatorEnv::getEnvConfig('phpmailer.smtp-password'),
'protocol' => PhabricatorEnv::getEnvConfig('phpmailer.smtp-protocol'),
'encoding' => PhabricatorEnv::getEnvConfig('phpmailer.smtp-encoding'),
'mailer' => PhabricatorEnv::getEnvConfig('phpmailer.mailer'),
);
}
/**
* @phutil-external-symbol class PHPMailer
*/

View file

@ -24,12 +24,6 @@ class PhabricatorMailImplementationPHPMailerLiteAdapter
);
}
public function newLegacyOptions() {
return array(
'encoding' => PhabricatorEnv::getEnvConfig('phpmailer.smtp-encoding'),
);
}
/**
* @phutil-external-symbol class PHPMailerLite
*/

View file

@ -94,10 +94,6 @@ final class PhabricatorMailImplementationPostmarkAdapter
);
}
public function newLegacyOptions() {
return array();
}
public function send() {
$access_token = $this->getOption('access-token');

View file

@ -26,13 +26,6 @@ final class PhabricatorMailImplementationSendGridAdapter
);
}
public function newLegacyOptions() {
return array(
'api-user' => PhabricatorEnv::getEnvConfig('sendgrid.api-user'),
'api-key' => PhabricatorEnv::getEnvConfig('sendgrid.api-key'),
);
}
public function setFrom($email, $name = '') {
$this->params['from'] = $email;
$this->params['from-name'] = $name;
@ -97,18 +90,9 @@ final class PhabricatorMailImplementationSendGridAdapter
}
public function send() {
$user = $this->getOption('api-user');
$key = $this->getOption('api-key');
if (!$user || !$key) {
throw new Exception(
pht(
"Configure '%s' and '%s' to use SendGrid for mail delivery.",
'sendgrid.api-user',
'sendgrid.api-key'));
}
$params = array();
$ii = 0;

View file

@ -22,10 +22,6 @@ final class PhabricatorMailImplementationTestAdapter
return array();
}
public function newLegacyOptions() {
return array();
}
public function prepareForSend(array $config = array()) {
$this->config = $config;
}

View file

@ -520,21 +520,7 @@ final class PhabricatorMetaMTAMail
$mailers = array();
$config = PhabricatorEnv::getEnvConfig('cluster.mailers');
if ($config === null) {
$mailer = PhabricatorEnv::newObjectFromConfig('metamta.mail-adapter');
$defaults = $mailer->newDefaultOptions();
$options = $mailer->newLegacyOptions();
$options = $options + $defaults;
$mailer
->setKey('default')
->setPriority(-1)
->setOptions($options);
$mailers[] = $mailer;
} else {
$adapters = PhabricatorMailImplementationAdapter::getAllAdapters();
$next_priority = -1;
@ -567,7 +553,6 @@ final class PhabricatorMetaMTAMail
$mailers[] = $mailer;
}
}
// Remove mailers with the wrong types.
if (isset($constraints['types'])) {

View file

@ -82,7 +82,7 @@ access to fix any mistakes.
attacker who has gained access to an administrator account in order to gain
greater access.
For example, an attacker who could modify `metamta.mail-adapter` (and other
For example, an attacker who could modify `cluster.mailers` (and other
similar options), could potentially reconfigure Phabricator to send mail
through an evil server they controlled, then trigger password resets on other
user accounts to compromise them.

View file

@ -129,7 +129,7 @@ like this:
- Add a Mailgun route with a `catch_all()` rule which takes the action
`forward("https://phabricator.example.com/mail/mailgun/")`. Replace the
example domain with your actual domain.
- Set the `mailgun.api-key` config key to your Mailgun API key.
- Configure a mailer in `cluster.mailers` with your Mailgun API key.
Postmark Setup
==============