2016-05-28 05:05:27 +08:00
|
|
|
import React from 'react';
|
|
|
|
import {isValidHost} from './onboarding-helpers';
|
|
|
|
import CreatePageForForm from './decorators/create-page-for-form';
|
|
|
|
import FormField from './form-field';
|
|
|
|
|
|
|
|
class AccountIMAPSettingsForm extends React.Component {
|
|
|
|
static displayName = 'AccountIMAPSettingsForm';
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
accountInfo: React.PropTypes.object,
|
|
|
|
errorFieldNames: React.PropTypes.array,
|
|
|
|
submitting: React.PropTypes.bool,
|
|
|
|
onConnect: React.PropTypes.func,
|
|
|
|
onFieldChange: React.PropTypes.func,
|
|
|
|
onFieldKeyPress: React.PropTypes.func,
|
|
|
|
};
|
|
|
|
|
|
|
|
static submitLabel = () => {
|
|
|
|
return 'Connect Account';
|
|
|
|
}
|
|
|
|
|
|
|
|
static titleLabel = () => {
|
2017-03-12 04:18:13 +08:00
|
|
|
return 'Set up your account';
|
2016-05-28 05:05:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static subtitleLabel = () => {
|
|
|
|
return 'Complete the IMAP and SMTP settings below to connect your account.';
|
|
|
|
}
|
|
|
|
|
|
|
|
static validateAccountInfo = (accountInfo) => {
|
|
|
|
let errorMessage = null;
|
|
|
|
const errorFieldNames = [];
|
|
|
|
|
|
|
|
for (const type of ['imap', 'smtp']) {
|
|
|
|
if (!accountInfo[`${type}_host`] || !accountInfo[`${type}_username`] || !accountInfo[`${type}_password`]) {
|
|
|
|
return {errorMessage, errorFieldNames, populated: false};
|
|
|
|
}
|
|
|
|
if (!isValidHost(accountInfo[`${type}_host`])) {
|
|
|
|
errorMessage = "Please provide a valid hostname or IP adddress.";
|
|
|
|
errorFieldNames.push(`${type}_host`);
|
|
|
|
}
|
2017-07-06 01:34:10 +08:00
|
|
|
// todo bg
|
|
|
|
// if (accountInfo[`${type}_host`] === 'imap.gmail.com') {
|
|
|
|
// errorMessage = "Please link Gmail accounts by choosing 'Google' on the account type screen.";
|
|
|
|
// errorFieldNames.push(`${type}_host`);
|
|
|
|
// }
|
2016-05-28 05:05:27 +08:00
|
|
|
if (!Number.isInteger(accountInfo[`${type}_port`] / 1)) {
|
|
|
|
errorMessage = "Please provide a valid port number.";
|
|
|
|
errorFieldNames.push(`${type}_port`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return {errorMessage, errorFieldNames, populated: true};
|
|
|
|
}
|
|
|
|
|
|
|
|
submit() {
|
|
|
|
this.props.onConnect();
|
|
|
|
}
|
|
|
|
|
[*] Revamp SSL options (including user-facing)
Summary:
Previously, the generic IMAP auth screen presented one security option to
users: "Require SSL". This was ambiguous and difficult to translate into
the correct security options behind the scenes, causing confusion and problems
connecting some accounts.
This patch does the following:
* Separates security settings for IMAP and SMTP, as these different protocols
may also require different SSL/TLS settings
* Reworks the generic IMAP auth page to allow specifying security settings
with higher fidelity. We looked at various different email apps and decided
that the best solution to this problem was to allow more detailed
specification of security settings and to ease the burden of more options
by having sane defaults that work correctly in the majority of cases.
This new screen allows users to pick from "SSL / TLS", "STARTTLS", or "none"
for the security settings for a protocol, and also to instruct us that
they're OK with us using known insecure SSL settings to connect to their
server by checking a checkbox.
We default to port 993 / SSL/TLS for IMAP and port 587 / STARTTLS for SMTP.
These are the most common settings for providers these days and will work
for most folks.
* Significantly tightens our default security. Now that we can allow folks to
opt-in to bad security, by default we should protect folks as best we can.
* Removes some now-unnecessary jank like specifying the SSLv3 "cipher"
in some custom SMTP configs. I don't think this was actually necessary
as SSLv3 is a protocol and not a valid cipher, but these custom
configs may have been necessary because of how the ssl_required flag was
linked between IMAP and SMTP before (and thus to specify different
settings for SMTP you'd have to override the SMTP config).
* Removes hard-coding of Gmail & Office365 settings in several
locations. (This was a major headache while working on the patch.)
This depends on version 2.0.1 of imap-provider-settings, which has major
breaking changes from version 1.0. See commit for more info:
https://github.com/nylas/imap-provider-settings/commit/9851054f9153476b6896d04893a40b4febc8986e
Among other things, I did a serious audit of the settings in this file and
"upgraded" a few servers which weren't using the SSL-enabled ports for their
provider to the secure ones. Hurray for nmap and openssl.
Test Plan: manual
Reviewers: evan, mark, juan, halla
Reviewed By: juan, halla
Differential Revision: https://phab.nylas.com/D4316
2017-04-06 08:34:13 +08:00
|
|
|
renderPortDropdown(protocol) {
|
|
|
|
if (!["imap", "smtp"].includes(protocol)) {
|
|
|
|
throw new Error(`Can't render port dropdown for protocol '${protocol}'`);
|
|
|
|
}
|
|
|
|
const {accountInfo, submitting, onFieldKeyPress, onFieldChange} = this.props;
|
|
|
|
|
|
|
|
if (protocol === "imap") {
|
|
|
|
return (
|
|
|
|
<span>
|
|
|
|
<label htmlFor="imap_port">Port:</label>
|
|
|
|
<select
|
|
|
|
id="imap_port"
|
|
|
|
tabIndex={0}
|
|
|
|
value={accountInfo.imap_port}
|
|
|
|
disabled={submitting}
|
|
|
|
onKeyPress={onFieldKeyPress}
|
|
|
|
onChange={onFieldChange}
|
|
|
|
>
|
|
|
|
<option value="143" key="143">143</option>
|
|
|
|
<option value="993" key="993">993</option>
|
|
|
|
</select>
|
|
|
|
</span>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
if (protocol === "smtp") {
|
|
|
|
return (
|
|
|
|
<span>
|
|
|
|
<label htmlFor="smtp_port">Port:</label>
|
|
|
|
<select
|
|
|
|
id="smtp_port"
|
|
|
|
tabIndex={0}
|
|
|
|
value={accountInfo.smtp_port}
|
|
|
|
disabled={submitting}
|
|
|
|
onKeyPress={onFieldKeyPress}
|
|
|
|
onChange={onFieldChange}
|
|
|
|
>
|
|
|
|
<option value="25" key="25">25</option>
|
|
|
|
<option value="465" key="465">465</option>
|
|
|
|
<option value="587" key="587">587</option>
|
|
|
|
</select>
|
|
|
|
</span>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
renderSecurityDropdown(protocol) {
|
|
|
|
const {accountInfo, submitting, onFieldKeyPress, onFieldChange} = this.props;
|
2016-05-28 05:05:27 +08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
[*] Revamp SSL options (including user-facing)
Summary:
Previously, the generic IMAP auth screen presented one security option to
users: "Require SSL". This was ambiguous and difficult to translate into
the correct security options behind the scenes, causing confusion and problems
connecting some accounts.
This patch does the following:
* Separates security settings for IMAP and SMTP, as these different protocols
may also require different SSL/TLS settings
* Reworks the generic IMAP auth page to allow specifying security settings
with higher fidelity. We looked at various different email apps and decided
that the best solution to this problem was to allow more detailed
specification of security settings and to ease the burden of more options
by having sane defaults that work correctly in the majority of cases.
This new screen allows users to pick from "SSL / TLS", "STARTTLS", or "none"
for the security settings for a protocol, and also to instruct us that
they're OK with us using known insecure SSL settings to connect to their
server by checking a checkbox.
We default to port 993 / SSL/TLS for IMAP and port 587 / STARTTLS for SMTP.
These are the most common settings for providers these days and will work
for most folks.
* Significantly tightens our default security. Now that we can allow folks to
opt-in to bad security, by default we should protect folks as best we can.
* Removes some now-unnecessary jank like specifying the SSLv3 "cipher"
in some custom SMTP configs. I don't think this was actually necessary
as SSLv3 is a protocol and not a valid cipher, but these custom
configs may have been necessary because of how the ssl_required flag was
linked between IMAP and SMTP before (and thus to specify different
settings for SMTP you'd have to override the SMTP config).
* Removes hard-coding of Gmail & Office365 settings in several
locations. (This was a major headache while working on the patch.)
This depends on version 2.0.1 of imap-provider-settings, which has major
breaking changes from version 1.0. See commit for more info:
https://github.com/nylas/imap-provider-settings/commit/9851054f9153476b6896d04893a40b4febc8986e
Among other things, I did a serious audit of the settings in this file and
"upgraded" a few servers which weren't using the SSL-enabled ports for their
provider to the secure ones. Hurray for nmap and openssl.
Test Plan: manual
Reviewers: evan, mark, juan, halla
Reviewed By: juan, halla
Differential Revision: https://phab.nylas.com/D4316
2017-04-06 08:34:13 +08:00
|
|
|
<span>
|
|
|
|
<label htmlFor={`${protocol}_security`}>Security:</label>
|
|
|
|
<select
|
|
|
|
id={`${protocol}_security`}
|
|
|
|
tabIndex={0}
|
|
|
|
value={accountInfo[`${protocol}_security`]}
|
|
|
|
disabled={submitting}
|
|
|
|
onKeyPress={onFieldKeyPress}
|
|
|
|
onChange={onFieldChange}
|
|
|
|
>
|
|
|
|
<option value="SSL / TLS" key="SSL">SSL / TLS</option>
|
|
|
|
<option value="STARTTLS" key="STARTTLS">STARTTLS</option>
|
2017-08-31 06:24:30 +08:00
|
|
|
<option value="none" key="none">None</option>
|
[*] Revamp SSL options (including user-facing)
Summary:
Previously, the generic IMAP auth screen presented one security option to
users: "Require SSL". This was ambiguous and difficult to translate into
the correct security options behind the scenes, causing confusion and problems
connecting some accounts.
This patch does the following:
* Separates security settings for IMAP and SMTP, as these different protocols
may also require different SSL/TLS settings
* Reworks the generic IMAP auth page to allow specifying security settings
with higher fidelity. We looked at various different email apps and decided
that the best solution to this problem was to allow more detailed
specification of security settings and to ease the burden of more options
by having sane defaults that work correctly in the majority of cases.
This new screen allows users to pick from "SSL / TLS", "STARTTLS", or "none"
for the security settings for a protocol, and also to instruct us that
they're OK with us using known insecure SSL settings to connect to their
server by checking a checkbox.
We default to port 993 / SSL/TLS for IMAP and port 587 / STARTTLS for SMTP.
These are the most common settings for providers these days and will work
for most folks.
* Significantly tightens our default security. Now that we can allow folks to
opt-in to bad security, by default we should protect folks as best we can.
* Removes some now-unnecessary jank like specifying the SSLv3 "cipher"
in some custom SMTP configs. I don't think this was actually necessary
as SSLv3 is a protocol and not a valid cipher, but these custom
configs may have been necessary because of how the ssl_required flag was
linked between IMAP and SMTP before (and thus to specify different
settings for SMTP you'd have to override the SMTP config).
* Removes hard-coding of Gmail & Office365 settings in several
locations. (This was a major headache while working on the patch.)
This depends on version 2.0.1 of imap-provider-settings, which has major
breaking changes from version 1.0. See commit for more info:
https://github.com/nylas/imap-provider-settings/commit/9851054f9153476b6896d04893a40b4febc8986e
Among other things, I did a serious audit of the settings in this file and
"upgraded" a few servers which weren't using the SSL-enabled ports for their
provider to the secure ones. Hurray for nmap and openssl.
Test Plan: manual
Reviewers: evan, mark, juan, halla
Reviewed By: juan, halla
Differential Revision: https://phab.nylas.com/D4316
2017-04-06 08:34:13 +08:00
|
|
|
</select>
|
|
|
|
</span>
|
|
|
|
<span style={{paddingLeft: '20px', paddingTop: '10px'}}>
|
2016-05-28 05:05:27 +08:00
|
|
|
<input
|
|
|
|
type="checkbox"
|
[*] Revamp SSL options (including user-facing)
Summary:
Previously, the generic IMAP auth screen presented one security option to
users: "Require SSL". This was ambiguous and difficult to translate into
the correct security options behind the scenes, causing confusion and problems
connecting some accounts.
This patch does the following:
* Separates security settings for IMAP and SMTP, as these different protocols
may also require different SSL/TLS settings
* Reworks the generic IMAP auth page to allow specifying security settings
with higher fidelity. We looked at various different email apps and decided
that the best solution to this problem was to allow more detailed
specification of security settings and to ease the burden of more options
by having sane defaults that work correctly in the majority of cases.
This new screen allows users to pick from "SSL / TLS", "STARTTLS", or "none"
for the security settings for a protocol, and also to instruct us that
they're OK with us using known insecure SSL settings to connect to their
server by checking a checkbox.
We default to port 993 / SSL/TLS for IMAP and port 587 / STARTTLS for SMTP.
These are the most common settings for providers these days and will work
for most folks.
* Significantly tightens our default security. Now that we can allow folks to
opt-in to bad security, by default we should protect folks as best we can.
* Removes some now-unnecessary jank like specifying the SSLv3 "cipher"
in some custom SMTP configs. I don't think this was actually necessary
as SSLv3 is a protocol and not a valid cipher, but these custom
configs may have been necessary because of how the ssl_required flag was
linked between IMAP and SMTP before (and thus to specify different
settings for SMTP you'd have to override the SMTP config).
* Removes hard-coding of Gmail & Office365 settings in several
locations. (This was a major headache while working on the patch.)
This depends on version 2.0.1 of imap-provider-settings, which has major
breaking changes from version 1.0. See commit for more info:
https://github.com/nylas/imap-provider-settings/commit/9851054f9153476b6896d04893a40b4febc8986e
Among other things, I did a serious audit of the settings in this file and
"upgraded" a few servers which weren't using the SSL-enabled ports for their
provider to the secure ones. Hurray for nmap and openssl.
Test Plan: manual
Reviewers: evan, mark, juan, halla
Reviewed By: juan, halla
Differential Revision: https://phab.nylas.com/D4316
2017-04-06 08:34:13 +08:00
|
|
|
id={`${protocol}_allow_insecure_ssl`}
|
2016-05-28 05:05:27 +08:00
|
|
|
disabled={submitting}
|
[*] Revamp SSL options (including user-facing)
Summary:
Previously, the generic IMAP auth screen presented one security option to
users: "Require SSL". This was ambiguous and difficult to translate into
the correct security options behind the scenes, causing confusion and problems
connecting some accounts.
This patch does the following:
* Separates security settings for IMAP and SMTP, as these different protocols
may also require different SSL/TLS settings
* Reworks the generic IMAP auth page to allow specifying security settings
with higher fidelity. We looked at various different email apps and decided
that the best solution to this problem was to allow more detailed
specification of security settings and to ease the burden of more options
by having sane defaults that work correctly in the majority of cases.
This new screen allows users to pick from "SSL / TLS", "STARTTLS", or "none"
for the security settings for a protocol, and also to instruct us that
they're OK with us using known insecure SSL settings to connect to their
server by checking a checkbox.
We default to port 993 / SSL/TLS for IMAP and port 587 / STARTTLS for SMTP.
These are the most common settings for providers these days and will work
for most folks.
* Significantly tightens our default security. Now that we can allow folks to
opt-in to bad security, by default we should protect folks as best we can.
* Removes some now-unnecessary jank like specifying the SSLv3 "cipher"
in some custom SMTP configs. I don't think this was actually necessary
as SSLv3 is a protocol and not a valid cipher, but these custom
configs may have been necessary because of how the ssl_required flag was
linked between IMAP and SMTP before (and thus to specify different
settings for SMTP you'd have to override the SMTP config).
* Removes hard-coding of Gmail & Office365 settings in several
locations. (This was a major headache while working on the patch.)
This depends on version 2.0.1 of imap-provider-settings, which has major
breaking changes from version 1.0. See commit for more info:
https://github.com/nylas/imap-provider-settings/commit/9851054f9153476b6896d04893a40b4febc8986e
Among other things, I did a serious audit of the settings in this file and
"upgraded" a few servers which weren't using the SSL-enabled ports for their
provider to the secure ones. Hurray for nmap and openssl.
Test Plan: manual
Reviewers: evan, mark, juan, halla
Reviewed By: juan, halla
Differential Revision: https://phab.nylas.com/D4316
2017-04-06 08:34:13 +08:00
|
|
|
checked={accountInfo[`${protocol}_allow_insecure_ssl`] || false}
|
2016-05-28 05:05:27 +08:00
|
|
|
onKeyPress={onFieldKeyPress}
|
|
|
|
onChange={onFieldChange}
|
|
|
|
/>
|
[*] Revamp SSL options (including user-facing)
Summary:
Previously, the generic IMAP auth screen presented one security option to
users: "Require SSL". This was ambiguous and difficult to translate into
the correct security options behind the scenes, causing confusion and problems
connecting some accounts.
This patch does the following:
* Separates security settings for IMAP and SMTP, as these different protocols
may also require different SSL/TLS settings
* Reworks the generic IMAP auth page to allow specifying security settings
with higher fidelity. We looked at various different email apps and decided
that the best solution to this problem was to allow more detailed
specification of security settings and to ease the burden of more options
by having sane defaults that work correctly in the majority of cases.
This new screen allows users to pick from "SSL / TLS", "STARTTLS", or "none"
for the security settings for a protocol, and also to instruct us that
they're OK with us using known insecure SSL settings to connect to their
server by checking a checkbox.
We default to port 993 / SSL/TLS for IMAP and port 587 / STARTTLS for SMTP.
These are the most common settings for providers these days and will work
for most folks.
* Significantly tightens our default security. Now that we can allow folks to
opt-in to bad security, by default we should protect folks as best we can.
* Removes some now-unnecessary jank like specifying the SSLv3 "cipher"
in some custom SMTP configs. I don't think this was actually necessary
as SSLv3 is a protocol and not a valid cipher, but these custom
configs may have been necessary because of how the ssl_required flag was
linked between IMAP and SMTP before (and thus to specify different
settings for SMTP you'd have to override the SMTP config).
* Removes hard-coding of Gmail & Office365 settings in several
locations. (This was a major headache while working on the patch.)
This depends on version 2.0.1 of imap-provider-settings, which has major
breaking changes from version 1.0. See commit for more info:
https://github.com/nylas/imap-provider-settings/commit/9851054f9153476b6896d04893a40b4febc8986e
Among other things, I did a serious audit of the settings in this file and
"upgraded" a few servers which weren't using the SSL-enabled ports for their
provider to the secure ones. Hurray for nmap and openssl.
Test Plan: manual
Reviewers: evan, mark, juan, halla
Reviewed By: juan, halla
Differential Revision: https://phab.nylas.com/D4316
2017-04-06 08:34:13 +08:00
|
|
|
<label htmlFor={`${protocol}_allow_insecure_ssl"`} className="checkbox">Allow insecure SSL</label>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
renderFieldsForType(type) {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<FormField field={`${type}_host`} title={"Server"} {...this.props} />
|
|
|
|
<div style={{textAlign: 'left'}}>
|
|
|
|
{this.renderPortDropdown(type)}
|
|
|
|
{this.renderSecurityDropdown(type)}
|
2016-05-28 05:05:27 +08:00
|
|
|
</div>
|
|
|
|
<FormField field={`${type}_username`} title={"Username"} {...this.props} />
|
|
|
|
<FormField field={`${type}_password`} title={"Password"} type="password" {...this.props} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div className="twocol">
|
|
|
|
<div className="col">
|
|
|
|
<div className="col-heading">Incoming Mail (IMAP):</div>
|
|
|
|
{this.renderFieldsForType('imap')}
|
|
|
|
</div>
|
|
|
|
<div className="col">
|
|
|
|
<div className="col-heading">Outgoing Mail (SMTP):</div>
|
|
|
|
{this.renderFieldsForType('smtp')}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default CreatePageForForm(AccountIMAPSettingsForm);
|