emailengine-app 2.79.3 → 2.79.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/deploy.yml +17 -1
- package/.github/workflows/release.yaml +17 -1
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +17 -0
- package/lib/account/auth-failure-backfill.js +176 -0
- package/lib/account/imap-data.js +74 -0
- package/lib/account.js +315 -108
- package/lib/api-routes/account-routes.js +7 -1
- package/lib/consts.js +23 -0
- package/lib/email-client/base-client.js +61 -31
- package/lib/email-client/gmail-client.js +6 -0
- package/lib/email-client/outlook-client.js +7 -0
- package/lib/enum-descriptions.js +1 -1
- package/lib/schemas.js +11 -1
- package/lib/ui-routes/account-routes.js +90 -7
- package/lib/ui-routes/dashboard-routes.js +22 -0
- package/lib/ui-routes/route-helpers.js +11 -5
- package/package.json +1 -1
- package/server.js +10 -0
- package/views/accounts/account.hbs +47 -2
- package/views/legal.hbs +1 -1
|
@@ -69,10 +69,13 @@ const {
|
|
|
69
69
|
EMAIL_COMPLAINT_NOTIFY,
|
|
70
70
|
MAX_INLINE_ATTACHMENT_SIZE,
|
|
71
71
|
DEFAULT_MAX_IMAP_AUTH_FAILURE_TIME,
|
|
72
|
+
AUTH_FAILURE_DISABLED_FIELD,
|
|
73
|
+
AUTH_FAILURE_DISABLED_DESCRIPTION,
|
|
72
74
|
EMAIL_DELIVERY_ERROR_NOTIFY,
|
|
73
75
|
EMAIL_SENT_NOTIFY
|
|
74
76
|
} = require('../consts');
|
|
75
77
|
const { buildRetentionPolicy } = require('../queue-retention');
|
|
78
|
+
const { readImapData } = require('../account/imap-data');
|
|
76
79
|
|
|
77
80
|
// Configure download chunk size from environment or use default
|
|
78
81
|
const DOWNLOAD_CHUNK_SIZE = getByteSize(readEnvValue('EENGINE_CHUNK_SIZE')) || DEFAULT_DOWNLOAD_CHUNK_SIZE;
|
|
@@ -594,18 +597,10 @@ class BaseClient {
|
|
|
594
597
|
* @returns {Promise<Boolean>} True when the account must not connect
|
|
595
598
|
*/
|
|
596
599
|
async isSyncDisabled() {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
try {
|
|
603
|
-
return !!JSON.parse(imapInfo).disabled;
|
|
604
|
-
} catch (err) {
|
|
605
|
-
// An unreadable blob is not a disable; stay noisy and let the connection proceed.
|
|
606
|
-
this.logger.error({ msg: 'Failed parsing IMAP data', err });
|
|
607
|
-
return false;
|
|
608
|
-
}
|
|
600
|
+
// An unreadable blob is not a disable; readImapData() stays noisy about it and the
|
|
601
|
+
// connection proceeds.
|
|
602
|
+
const { imapData } = await readImapData(this.redis, this.getAccountKey(), this.logger);
|
|
603
|
+
return !!(imapData && imapData.disabled);
|
|
609
604
|
}
|
|
610
605
|
|
|
611
606
|
/**
|
|
@@ -635,27 +630,41 @@ class BaseClient {
|
|
|
635
630
|
async disableAfterAuthFailures({ event, firstError, errorCount, data }) {
|
|
636
631
|
const accountKey = this.getAccountKey();
|
|
637
632
|
|
|
638
|
-
let imapData;
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
imapData = JSON.parse(imapInfo);
|
|
643
|
-
} catch (err) {
|
|
644
|
-
// Rewriting a blob that does not parse would replace the account's IMAP
|
|
645
|
-
// configuration with a bare flag, so leave it alone and stay noisy instead.
|
|
646
|
-
this.logger.error({ msg: 'Failed parsing IMAP data', err });
|
|
647
|
-
return false;
|
|
648
|
-
}
|
|
633
|
+
let { imapData, invalid } = await readImapData(this.redis, accountKey, this.logger);
|
|
634
|
+
if (invalid) {
|
|
635
|
+
// Leave an unreadable configuration alone rather than replacing it with a bare flag.
|
|
636
|
+
return false;
|
|
649
637
|
}
|
|
650
638
|
|
|
651
639
|
if (!imapData) {
|
|
652
640
|
// No IMAP configuration: an OAuth2 account. Only synthesize the flag when there is an
|
|
653
641
|
// OAuth2 credential for the failures to be about, so an account still being created
|
|
654
642
|
// cannot be marked disabled on its way in.
|
|
655
|
-
const
|
|
656
|
-
if (!
|
|
643
|
+
const oauth2Info = await this.redis.hget(accountKey, 'oauth2');
|
|
644
|
+
if (!oauth2Info) {
|
|
657
645
|
return false;
|
|
658
646
|
}
|
|
647
|
+
|
|
648
|
+
let oauth2Data;
|
|
649
|
+
try {
|
|
650
|
+
oauth2Data = JSON.parse(oauth2Info);
|
|
651
|
+
} catch (err) {
|
|
652
|
+
// an unreadable credential is not a delegation
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
if (oauth2Data?.auth?.delegatedUser && oauth2Data?.auth?.delegatedAccount) {
|
|
656
|
+
// A delegated account (an Outlook shared mailbox, say) has no credential of its
|
|
657
|
+
// own: the failures counted here are those of the account it borrows the token
|
|
658
|
+
// from, and re-authorizing that account would lift nothing here. Leave the park to
|
|
659
|
+
// the account that owns the credential, where re-authorization is the fix.
|
|
660
|
+
this.logger.debug({
|
|
661
|
+
msg: 'Skipped disabling a delegated account after authentication failures',
|
|
662
|
+
account: this.account,
|
|
663
|
+
delegatedAccount: oauth2Data.auth.delegatedAccount
|
|
664
|
+
});
|
|
665
|
+
return false;
|
|
666
|
+
}
|
|
667
|
+
|
|
659
668
|
imapData = {};
|
|
660
669
|
}
|
|
661
670
|
|
|
@@ -668,29 +677,50 @@ class BaseClient {
|
|
|
668
677
|
// Disable IMAP and reset error counters
|
|
669
678
|
const disableTxn = createTransaction(this.redis, { logger: this.logger });
|
|
670
679
|
disableTxn.add('hSetExists', accountKey, 'imap', JSON.stringify(imapData));
|
|
680
|
+
// Records that this disable is ours, not the operator's send-only switch. Account
|
|
681
|
+
// re-registration and re-authorization lift the flag only when this marker is present,
|
|
682
|
+
// so re-authorizing a deliberately send-only account never starts syncing its mailbox.
|
|
683
|
+
disableTxn.add('hSetExists', accountKey, AUTH_FAILURE_DISABLED_FIELD, new Date().toISOString());
|
|
671
684
|
disableTxn.add('hdel', accountKey, 'lastError:errorCount', 'lastError:first');
|
|
672
685
|
disableTxn.add(
|
|
673
686
|
'hSetExists',
|
|
674
687
|
accountKey,
|
|
675
688
|
'lastErrorState',
|
|
676
689
|
JSON.stringify({
|
|
677
|
-
description:
|
|
690
|
+
description: AUTH_FAILURE_DISABLED_DESCRIPTION,
|
|
678
691
|
response: data.response
|
|
679
692
|
})
|
|
680
693
|
);
|
|
681
|
-
await disableTxn.exec();
|
|
694
|
+
const { error } = await disableTxn.exec();
|
|
695
|
+
|
|
696
|
+
if (error) {
|
|
697
|
+
// exec() reports a command-level failure in `error` rather than throwing it, so an
|
|
698
|
+
// unchecked call would announce a park that was never stored: the caller sends the
|
|
699
|
+
// "account was switched off" notification, the connection is torn down, and the flag
|
|
700
|
+
// the connection gates read is still absent, so the account reconnects and keeps
|
|
701
|
+
// hammering the provider. Say nothing happened and let the next failure retry, the same
|
|
702
|
+
// way clearAuthFailureDisable() treats a failed lift.
|
|
703
|
+
this.logger.error({ msg: 'Failed to disable IMAP for account', account: this.account, err: error });
|
|
704
|
+
return false;
|
|
705
|
+
}
|
|
682
706
|
|
|
683
707
|
this.logger.warn({
|
|
684
|
-
msg:
|
|
708
|
+
msg: AUTH_FAILURE_DISABLED_DESCRIPTION,
|
|
685
709
|
errorEvent: event,
|
|
686
710
|
firstError: firstError.toISOString(),
|
|
687
711
|
timeThreshold: MAX_IMAP_AUTH_FAILURE_TIME,
|
|
688
712
|
errorCount
|
|
689
713
|
});
|
|
690
714
|
|
|
691
|
-
// Close the connection after disabling
|
|
692
|
-
|
|
693
|
-
|
|
715
|
+
// Close the connection after disabling. Nothing awaits this, and for the Gmail API and
|
|
716
|
+
// Graph clients close() is async and writes the account state, so a rejection here would
|
|
717
|
+
// otherwise reach the global handler and take the whole worker down with it.
|
|
718
|
+
setImmediate(async () => {
|
|
719
|
+
try {
|
|
720
|
+
await this.close();
|
|
721
|
+
} catch (err) {
|
|
722
|
+
this.logger.error({ msg: 'Failed to close the connection of a disabled account', account: this.account, err });
|
|
723
|
+
}
|
|
694
724
|
});
|
|
695
725
|
|
|
696
726
|
return true;
|
|
@@ -618,6 +618,12 @@ class GmailClient extends BaseClient {
|
|
|
618
618
|
}
|
|
619
619
|
|
|
620
620
|
async reconnect() {
|
|
621
|
+
// A closed instance can be revived here, as IMAPClient.reconnect(force) does: every timer
|
|
622
|
+
// and the watch setup return on `closed`, and init() does not reset it, so without this a
|
|
623
|
+
// reconnect after close() reported a connected account that never synced. The auth-failure
|
|
624
|
+
// safety net produces exactly that instance - the park closes the client but leaves it
|
|
625
|
+
// assigned, and switching the flag back off through PUT /v1/account reconnects it in place.
|
|
626
|
+
this.closed = false;
|
|
621
627
|
return await this.init({ forceWatchRenewal: true });
|
|
622
628
|
}
|
|
623
629
|
|
|
@@ -483,6 +483,13 @@ class OutlookClient extends BaseClient {
|
|
|
483
483
|
* Reconnect to the account (re-initialize)
|
|
484
484
|
*/
|
|
485
485
|
async reconnect() {
|
|
486
|
+
// A closed instance can be revived here, as IMAPClient.reconnect(force) does: the
|
|
487
|
+
// subscription setup and the sync paths return on `closed`, and init() does not reset it,
|
|
488
|
+
// so without this a reconnect after close() reported a connected account that never
|
|
489
|
+
// received a notification. The auth-failure safety net produces exactly that instance - the
|
|
490
|
+
// park closes the client but leaves it assigned, and switching the flag back off through
|
|
491
|
+
// PUT /v1/account reconnects it in place.
|
|
492
|
+
this.closed = false;
|
|
486
493
|
return await this.init();
|
|
487
494
|
}
|
|
488
495
|
|
package/lib/enum-descriptions.js
CHANGED
|
@@ -27,7 +27,7 @@ const ENUM_DESCRIPTIONS = {
|
|
|
27
27
|
paused: 'Syncing was paused through the API. No connection is maintained',
|
|
28
28
|
authenticationError: 'The credentials were rejected. Requires re-authentication before syncing resumes',
|
|
29
29
|
connectError: 'The server could not be reached or the TLS handshake failed. Retried with backoff',
|
|
30
|
-
unset: '
|
|
30
|
+
unset: 'The account is not syncing: either no IMAP or OAuth2 configuration is set, or syncing was switched off - by the operator, or automatically after repeated authentication failures'
|
|
31
31
|
},
|
|
32
32
|
|
|
33
33
|
outboxStatus: {
|
package/lib/schemas.js
CHANGED
|
@@ -1635,7 +1635,17 @@ const accountSchemas = {
|
|
|
1635
1635
|
.example('full')
|
|
1636
1636
|
.description('Override the global IMAP indexing strategy for this account')
|
|
1637
1637
|
.meta({ enumDescriptions: ENUM_DESCRIPTIONS.imapIndexer, usage: FIELD_USAGE.imapIndexer })
|
|
1638
|
-
.label('AccountImapIndexer')
|
|
1638
|
+
.label('AccountImapIndexer'),
|
|
1639
|
+
|
|
1640
|
+
// Read-only, and no `.label()`: the generator inlines scalars, so a label here would name a
|
|
1641
|
+
// public type that never appears in the document.
|
|
1642
|
+
authFailureDisabledAt: Joi.date()
|
|
1643
|
+
.iso()
|
|
1644
|
+
.allow(null)
|
|
1645
|
+
.example('2021-03-22T13:13:31.000Z')
|
|
1646
|
+
.description(
|
|
1647
|
+
"When EmailEngine switched syncing off for this account after repeated authentication failures, or `null`. Read-only. Supply working credentials - re-authorize an OAuth2 account, or save new IMAP settings - and syncing resumes. `imap.disabled` is also the operator's own send-only switch, so this is what tells an automatic disable from a deliberate one."
|
|
1648
|
+
)
|
|
1639
1649
|
};
|
|
1640
1650
|
|
|
1641
1651
|
const googleProjectIdSchema = Joi.string()
|
|
@@ -16,7 +16,7 @@ const tokens = require('../tokens');
|
|
|
16
16
|
const { redis, documentsQueue } = require('../db');
|
|
17
17
|
const getSecret = require('../get-secret');
|
|
18
18
|
const capa = require('../capa');
|
|
19
|
-
const { Account } = require('../account');
|
|
19
|
+
const { Account, authFailureDisabledAt, isOperatorDisabled } = require('../account');
|
|
20
20
|
const { Gateway } = require('../gateway');
|
|
21
21
|
const { autodetectImapSettings, resolveAppPassword, getAppPassword } = require('../autodetect-imap-settings');
|
|
22
22
|
const { atomicIncrement } = require('../redis-operations');
|
|
@@ -1387,12 +1387,29 @@ function init(args) {
|
|
|
1387
1387
|
|
|
1388
1388
|
const canReadMail = (accountData.imap || accountData.oauth2) && !(accountData.imap && accountData.imap.disabled) && !DISABLE_MESSAGE_BROWSER;
|
|
1389
1389
|
|
|
1390
|
+
// The auth-failure safety net parks an account by setting imap.disabled, and for a
|
|
1391
|
+
// Gmail API or Outlook account that is a flag with nowhere to show: the IMAP and SMTP
|
|
1392
|
+
// cards below are hidden for API accounts, so the parked account reported nothing but
|
|
1393
|
+
// a neutral "Not syncing" and the operator had no way back that did not involve a raw
|
|
1394
|
+
// API call.
|
|
1395
|
+
const disabledByAuthFailureAt = authFailureDisabledAt(accountData);
|
|
1396
|
+
|
|
1390
1397
|
// Top-of-page alert for the account's primary problem, so a broken account is
|
|
1391
1398
|
// impossible to miss. Gated on the effective connection state (stateLabel.type) so a
|
|
1392
1399
|
// recovered account never shows a stale error; a stalled sync is surfaced separately
|
|
1393
1400
|
// because the account can otherwise be connected.
|
|
1394
1401
|
let accountAlert = null;
|
|
1395
|
-
if (
|
|
1402
|
+
if (disabledByAuthFailureAt) {
|
|
1403
|
+
// Ahead of the state alert: a parked account is not connecting at all, so why it
|
|
1404
|
+
// was switched off is the more actionable of the two.
|
|
1405
|
+
accountAlert = {
|
|
1406
|
+
title: 'Syncing was switched off',
|
|
1407
|
+
message:
|
|
1408
|
+
'EmailEngine stopped connecting this account after repeated authentication failures. Re-authenticating it turns syncing back on; "Resume syncing" retries with the stored credentials.',
|
|
1409
|
+
timeLabel: 'Switched off',
|
|
1410
|
+
time: disabledByAuthFailureAt
|
|
1411
|
+
};
|
|
1412
|
+
} else if (accountData.stateLabel && accountData.stateLabel.type === 'error') {
|
|
1396
1413
|
accountAlert = {
|
|
1397
1414
|
title: accountData.stateLabel.name,
|
|
1398
1415
|
message: accountData.stateLabel.error
|
|
@@ -1436,6 +1453,7 @@ function init(args) {
|
|
|
1436
1453
|
menuAccounts: true,
|
|
1437
1454
|
account: accountData,
|
|
1438
1455
|
accountAlert,
|
|
1456
|
+
accountParked: !!disabledByAuthFailureAt,
|
|
1439
1457
|
logs: logInfo,
|
|
1440
1458
|
smtpError: accountData.smtpStatus && accountData.smtpStatus.status === 'error',
|
|
1441
1459
|
|
|
@@ -1559,10 +1577,17 @@ function init(args) {
|
|
|
1559
1577
|
let account = request.params.account;
|
|
1560
1578
|
try {
|
|
1561
1579
|
request.logger.info({ msg: 'Requesting account reconnect', account });
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
}
|
|
1565
|
-
|
|
1580
|
+
|
|
1581
|
+
// Through requestReconnect() rather than dispatching here, so this button and
|
|
1582
|
+
// PUT /v1/account/{account}/reconnect share one answer. It declines for an account
|
|
1583
|
+
// the auth-failure safety net switched off, where the dispatch would be a no-op -
|
|
1584
|
+
// and since this caller always asks to reconnect, a false is that refusal. The
|
|
1585
|
+
// button is also rendered disabled in that state; this is what makes the refusal
|
|
1586
|
+
// real rather than cosmetic.
|
|
1587
|
+
let accountObject = new Account({ redis, account, call, secret: await getSecret() });
|
|
1588
|
+
|
|
1589
|
+
if (!(await accountObject.requestReconnect({ reconnect: true }))) {
|
|
1590
|
+
return { success: false, error: 'Syncing is switched off for this account. Use "Resume syncing" to turn it back on.' };
|
|
1566
1591
|
}
|
|
1567
1592
|
|
|
1568
1593
|
return {
|
|
@@ -1590,6 +1615,59 @@ function init(args) {
|
|
|
1590
1615
|
}
|
|
1591
1616
|
});
|
|
1592
1617
|
|
|
1618
|
+
// Turns an account back on after the auth-failure safety net switched it off. The only admin
|
|
1619
|
+
// UI route that reaches the flag for a Gmail API or Outlook account: their IMAP card, and with
|
|
1620
|
+
// it the "Disable IMAP" checkbox an IMAP account is re-enabled through, is not rendered.
|
|
1621
|
+
//
|
|
1622
|
+
// Lifts nothing but the safety net's own disable (see Account.clearAuthFailureDisable), so it
|
|
1623
|
+
// cannot be used to un-do an operator's deliberate send-only switch.
|
|
1624
|
+
server.route({
|
|
1625
|
+
method: 'POST',
|
|
1626
|
+
path: '/admin/accounts/{account}/resume',
|
|
1627
|
+
async handler(request) {
|
|
1628
|
+
let account = request.params.account;
|
|
1629
|
+
try {
|
|
1630
|
+
// clearAuthFailureDisable() needs nothing but the account hash, and the reconnect
|
|
1631
|
+
// below is dispatched from this module's own channel
|
|
1632
|
+
let accountObject = new Account({ redis, account });
|
|
1633
|
+
|
|
1634
|
+
if (!(await accountObject.clearAuthFailureDisable())) {
|
|
1635
|
+
return { success: false, error: 'This account was not switched off by EmailEngine' };
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
request.logger.info({ msg: 'Resumed an account that was switched off after authentication failures', account });
|
|
1639
|
+
|
|
1640
|
+
try {
|
|
1641
|
+
await call({ cmd: 'reconnect', account });
|
|
1642
|
+
} catch (err) {
|
|
1643
|
+
// The flag is already lifted, so the account is no longer parked. Losing the
|
|
1644
|
+
// dispatch only delays the connection until the next periodic reconnect.
|
|
1645
|
+
request.logger.error({ msg: 'Reconnect request failed', action: 'resume_account', account, err });
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
return { success: true };
|
|
1649
|
+
} catch (err) {
|
|
1650
|
+
request.logger.error({ msg: 'Failed to resume account', err, account });
|
|
1651
|
+
return { success: false, error: err.message };
|
|
1652
|
+
}
|
|
1653
|
+
},
|
|
1654
|
+
options: {
|
|
1655
|
+
validate: {
|
|
1656
|
+
options: {
|
|
1657
|
+
stripUnknown: true,
|
|
1658
|
+
abortEarly: false,
|
|
1659
|
+
convert: true
|
|
1660
|
+
},
|
|
1661
|
+
|
|
1662
|
+
failAction,
|
|
1663
|
+
|
|
1664
|
+
params: Joi.object({
|
|
1665
|
+
account: accountIdSchema.required()
|
|
1666
|
+
})
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
});
|
|
1670
|
+
|
|
1593
1671
|
server.route({
|
|
1594
1672
|
method: 'POST',
|
|
1595
1673
|
path: '/admin/accounts/{account}/sync',
|
|
@@ -1834,7 +1912,12 @@ function init(args) {
|
|
|
1834
1912
|
|
|
1835
1913
|
const values = Object.assign({}, flattenObjectKeys(accountData), {
|
|
1836
1914
|
imap: true,
|
|
1837
|
-
|
|
1915
|
+
// The checkbox is the operator's own switch, so a park by the auth-failure safety
|
|
1916
|
+
// net does not pre-check it: the page alert promises that saving new credentials
|
|
1917
|
+
// turns syncing back on, and a pre-checked box would have made every such save an
|
|
1918
|
+
// explicit request to keep the account off. Unchecked, the connection fields are
|
|
1919
|
+
// shown and the save writes `disabled: false`, which lifts the park.
|
|
1920
|
+
imap_disabled: (!accountData.imap && !accountData.oauth2) || isOperatorDisabled(accountData),
|
|
1838
1921
|
imap_tls_ignoreCertErrors: !!(accountData.imap && accountData.imap.tls && accountData.imap.tls.rejectUnauthorized === false),
|
|
1839
1922
|
smtp: !!accountData.smtp,
|
|
1840
1923
|
smtp_tls_ignoreCertErrors: !!(accountData.smtp && accountData.smtp.tls && accountData.smtp.tls.rejectUnauthorized === false),
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// /admin dashboard (stats counters), the legal page, and the upgrade page. Extracted
|
|
5
5
|
// verbatim from lib/routes-ui.js. The API reference lives in reference-routes.js.
|
|
6
6
|
|
|
7
|
+
const pathlib = require('path');
|
|
7
8
|
const { getStats, getBoolean, readEnvValue } = require('../tools');
|
|
8
9
|
const settings = require('../settings');
|
|
9
10
|
const { redis } = require('../db');
|
|
@@ -124,6 +125,27 @@ function init(args) {
|
|
|
124
125
|
}
|
|
125
126
|
});
|
|
126
127
|
|
|
128
|
+
// The same dependency inventory /sbom.json serves, on the admin surface.
|
|
129
|
+
//
|
|
130
|
+
// /sbom.json is deliberately behind the api-token strategy - the file names every package and
|
|
131
|
+
// version the instance runs - and that strategy has no session-cookie fallback, so a link to
|
|
132
|
+
// it from a rendered admin page answered a signed-in admin with a 401. Rather than widening
|
|
133
|
+
// the API gate for a browser, the download an operator clicks is served where their session
|
|
134
|
+
// already authenticates them, inside the EENGINE_ADMIN_ACCESS_ADDRESSES perimeter.
|
|
135
|
+
server.route({
|
|
136
|
+
method: 'GET',
|
|
137
|
+
path: '/admin/legal/sbom.json',
|
|
138
|
+
handler: {
|
|
139
|
+
file: {
|
|
140
|
+
path: pathlib.join(__dirname, '..', '..', 'sbom.json'),
|
|
141
|
+
confine: false,
|
|
142
|
+
// Named for the operator saving it, not for the route it came from
|
|
143
|
+
filename: 'sbom.json',
|
|
144
|
+
mode: 'attachment'
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
127
149
|
server.route({
|
|
128
150
|
method: 'GET',
|
|
129
151
|
path: '/admin/upgrade',
|
|
@@ -19,7 +19,7 @@ const psl = require('psl');
|
|
|
19
19
|
const settings = require('../settings');
|
|
20
20
|
const { redis } = require('../db');
|
|
21
21
|
const { toolGrants } = require('../mcp/tools');
|
|
22
|
-
const { Account, accountsExist, accountSummary } = require('../account');
|
|
22
|
+
const { Account, accountsExist, accountSummary, isAuthFailureDisabled } = require('../account');
|
|
23
23
|
const { REDIS_PREFIX, DEFAULT_PAGE_SIZE } = require('../consts');
|
|
24
24
|
const { oauth2ProviderData } = require('../oauth2-apps');
|
|
25
25
|
const exampleDocumentsPayloads = require('../payload-examples-documents.json');
|
|
@@ -205,12 +205,18 @@ function formatAccountData(account, gt) {
|
|
|
205
205
|
|
|
206
206
|
account.stateLabel = accountStateLabel(account.state, { lastErrorState: account.lastErrorState, disabledReason: account.disabledReason }, gt);
|
|
207
207
|
|
|
208
|
-
//
|
|
209
|
-
|
|
208
|
+
// An account the auth-failure safety net switched off reports the neutral "Not syncing", which
|
|
209
|
+
// says nothing about why it stopped or that a human has to act. Override the label to say so.
|
|
210
|
+
//
|
|
211
|
+
// Keyed on the marker the safety net writes, or on the exact signature the releases before the
|
|
212
|
+
// marker left behind, not on `imap.disabled` plus any leftover error: that flag is also the
|
|
213
|
+
// operator's send-only switch, so the old guess badged a deliberately send-only account
|
|
214
|
+
// "Connection failed" if it had ever failed to connect.
|
|
215
|
+
if (isAuthFailureDisabled(account)) {
|
|
210
216
|
account.stateLabel = {
|
|
211
217
|
type: 'error',
|
|
212
|
-
name: '
|
|
213
|
-
error: account.lastErrorState.description || account.lastErrorState.response
|
|
218
|
+
name: 'Syncing switched off',
|
|
219
|
+
error: account.lastErrorState && (account.lastErrorState.description || account.lastErrorState.response)
|
|
214
220
|
};
|
|
215
221
|
}
|
|
216
222
|
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -125,6 +125,7 @@ const Joi = require('joi');
|
|
|
125
125
|
const { settingsSchema } = require('./lib/schemas');
|
|
126
126
|
const settings = require('./lib/settings');
|
|
127
127
|
const { oauth2Apps } = require('./lib/oauth2-apps');
|
|
128
|
+
const { backfillAuthFailureDisabled } = require('./lib/account/auth-failure-backfill');
|
|
128
129
|
const { documentStoreFeatureEnabled } = require('./lib/document-store');
|
|
129
130
|
const { attachBeacon, persistBeaconMarkers } = require('./lib/license-beacon');
|
|
130
131
|
const tokens = require('./lib/tokens');
|
|
@@ -3254,6 +3255,15 @@ const startApplication = async () => {
|
|
|
3254
3255
|
logger.error({ msg: 'Failed to migrate legacy OAuth2 apps', err });
|
|
3255
3256
|
}
|
|
3256
3257
|
|
|
3258
|
+
// Give accounts that 2.79.3 switched off after repeated authentication failures the provenance
|
|
3259
|
+
// marker 2.79.4 recognises, so re-authorizing one resumes it instead of silently doing nothing.
|
|
3260
|
+
// A failure is not fatal: the completion key is written last, so the next startup re-enters.
|
|
3261
|
+
try {
|
|
3262
|
+
await backfillAuthFailureDisabled();
|
|
3263
|
+
} catch (err) {
|
|
3264
|
+
logger.error({ msg: 'Failed to backfill the auth-failure disable marker', err });
|
|
3265
|
+
}
|
|
3266
|
+
|
|
3257
3267
|
// Apply prepared settings
|
|
3258
3268
|
if (preparedSettings) {
|
|
3259
3269
|
logger.debug({ msg: 'Applying configuration', settingsKeys: Object.keys(preparedSettings) });
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
{{#if accountAlert.message}}
|
|
9
9
|
<div class="break-words"><small>{{accountAlert.message}}</small></div>
|
|
10
10
|
{{/if}}
|
|
11
|
+
{{#if accountAlert.time}}
|
|
12
|
+
<div><small>{{accountAlert.timeLabel}} <span class="local-date-time" data-time="{{accountAlert.time}}"></span></small></div>
|
|
13
|
+
{{/if}}
|
|
11
14
|
{{/ui/alert-banner}}
|
|
12
15
|
{{/if}}
|
|
13
16
|
|
|
@@ -29,8 +32,13 @@
|
|
|
29
32
|
<div class="bg-base-content/10 mx-1 hidden h-6 w-px self-center sm:block" aria-hidden="true"></div>
|
|
30
33
|
|
|
31
34
|
{{!-- Operations: act on this account now --}}
|
|
32
|
-
{{
|
|
33
|
-
|
|
35
|
+
{{!-- Disabled while the account is switched off: a reconnect rebuilds the connection,
|
|
36
|
+
but init() checks the disable flag before it dials out and returns without
|
|
37
|
+
connecting, so the click would report success and do nothing. --}}
|
|
38
|
+
{{#> ui/tooltip text=(when accountParked "Syncing is switched off - use Resume syncing instead" "Close and re-open the connection")}}
|
|
39
|
+
{{!-- pointer-events-none so the tooltip above still explains why: browsers dispatch no
|
|
40
|
+
mouse events for a disabled control, so without it the wrapper never sees the hover --}}
|
|
41
|
+
<button type="button" class="btn btn-soft btn-sm{{#if accountParked}} pointer-events-none{{/if}}" id="request-reconnect"{{#if accountParked}} disabled{{/if}}>
|
|
34
42
|
<span class="icon-[tabler--refresh] size-4" id="reconnect-icon"></span> Reconnect
|
|
35
43
|
</button>
|
|
36
44
|
{{/ui/tooltip}}
|
|
@@ -51,6 +59,14 @@
|
|
|
51
59
|
{{/ui/tooltip}}
|
|
52
60
|
{{/if}}
|
|
53
61
|
|
|
62
|
+
{{!-- Only for an account the auth-failure safety net switched off. An API account has
|
|
63
|
+
no IMAP card, so this is the one control that reaches the flag. --}}
|
|
64
|
+
{{#if accountParked}}
|
|
65
|
+
{{#> ui/tooltip text="Turn syncing back on with the stored credentials"}}
|
|
66
|
+
{{> ui/btn bare=true style="soft" size="sm" id="request-resume" icon="icon-[tabler--player-play]" label="Resume syncing"}}
|
|
67
|
+
{{/ui/tooltip}}
|
|
68
|
+
{{/if}}
|
|
69
|
+
|
|
54
70
|
{{#if canSend}}
|
|
55
71
|
{{#unless gateways}}
|
|
56
72
|
{{#> ui/tooltip text="Test SMTP delivery settings for this account"}}
|
|
@@ -961,6 +977,35 @@ submitLabel="Delete account"}}
|
|
|
961
977
|
})
|
|
962
978
|
});
|
|
963
979
|
|
|
980
|
+
// Only rendered for an account the auth-failure safety net switched off
|
|
981
|
+
const requestResumeElm = document.getElementById('request-resume');
|
|
982
|
+
if (requestResumeElm) {
|
|
983
|
+
requestResumeElm.addEventListener('click', e => {
|
|
984
|
+
e.preventDefault();
|
|
985
|
+
// The disabled button is the re-entrancy guard
|
|
986
|
+
if (requestResumeElm.disabled) {
|
|
987
|
+
return
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
uiButtonBusy(requestResumeElm, true);
|
|
991
|
+
const account = document.getElementById('account-id').value.trim();
|
|
992
|
+
uiPostJson(`/admin/accounts/${account}/resume`, {}).then(data => {
|
|
993
|
+
if (data.success) {
|
|
994
|
+
// Both the button and the alert explaining why it was there belong to the
|
|
995
|
+
// switched-off state, so reload rather than leave either behind. No toast:
|
|
996
|
+
// the navigation would destroy it before it could be read.
|
|
997
|
+
window.location.reload();
|
|
998
|
+
return;
|
|
999
|
+
}
|
|
1000
|
+
uiButtonBusy(requestResumeElm, false);
|
|
1001
|
+
uiToastResult(data, 'Syncing resumed', 'Failed to resume syncing');
|
|
1002
|
+
}).catch(err => {
|
|
1003
|
+
uiButtonBusy(requestResumeElm, false);
|
|
1004
|
+
showToast('Request failed\n' + err.message, 'alert-triangle');
|
|
1005
|
+
})
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
|
|
964
1009
|
const syncAccount = async () => {
|
|
965
1010
|
const account = document.getElementById('account-id').value.trim();
|
|
966
1011
|
|
package/views/legal.hbs
CHANGED
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
</li>
|
|
72
72
|
|
|
73
73
|
<li class="px-6 py-4">
|
|
74
|
-
<a href="/sbom.json" download="sbom.json" class="link link-animated">
|
|
74
|
+
<a href="/admin/legal/sbom.json" download="sbom.json" class="link link-animated">
|
|
75
75
|
<span class="icon-[tabler--cloud-download] size-4 align-text-bottom"></span>
|
|
76
76
|
<strong>Software Bill of Materials (SBOM)</strong>
|
|
77
77
|
</a>
|