emailengine-app 2.79.5 → 2.79.7
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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +24 -0
- package/data/google-crawlers.json +1 -1
- package/lib/api-routes/account-routes.js +6 -3
- package/lib/api-routes/behavior-notes.js +6 -3
- package/lib/consts.js +4 -2
- package/lib/email-client/imap/mailbox.js +32 -8
- package/lib/enum-descriptions.js +1 -1
- package/lib/passkeys.js +39 -7
- package/lib/sso.js +47 -4
- package/lib/tools.js +19 -0
- package/lib/ui-routes/account-routes.js +9 -1
- package/lib/ui-routes/auth-routes.js +158 -62
- package/lib/ui-routes/network-config-routes.js +10 -1
- package/package.json +21 -21
- package/sbom.json +1 -1
- package/static/css/flyonui.css +1 -1
- package/static/css/src/app.tailwind.css +55 -0
- package/static/js/app.js +4 -35
- package/static/js/passkey-register.js +50 -1
- package/static/js/public.js +128 -0
- package/static/js/ui.js +183 -6
- package/static/licenses.html +375 -774
- package/translations/messages.pot +66 -66
- package/views/account/passkeys.hbs +133 -0
- package/views/account/security.hbs +300 -319
- package/views/accounts/account.hbs +84 -114
- package/views/accounts/register/imap-server.hbs +8 -10
- package/views/config/document-store/index.hbs +6 -6
- package/views/config/license.hbs +4 -1
- package/views/config/oauth/app.hbs +1 -1
- package/views/config/oauth/edit.hbs +1 -1
- package/views/config/oauth/new.hbs +1 -1
- package/views/config/webhooks.hbs +7 -6
- package/views/partials/gateway_js.hbs +7 -6
- package/views/partials/ui/btn.hbs +8 -2
- package/views/partials/ui/confirm-modal.hbs +2 -3
- package/views/partials/ui/empty-state.hbs +25 -0
- package/views/partials/webhooks_editor_functions.hbs +5 -5
- package/workers/api.js +56 -18
package/workers/api.js
CHANGED
|
@@ -42,7 +42,8 @@ const {
|
|
|
42
42
|
claimFormNonce,
|
|
43
43
|
releaseFormNonce,
|
|
44
44
|
setAdminSession,
|
|
45
|
-
isEndedSession
|
|
45
|
+
isEndedSession,
|
|
46
|
+
reloadTlsServers
|
|
46
47
|
} = require('../lib/tools');
|
|
47
48
|
const { matchIp, resolveClientIp, detectAutomatedRequest } = require('../lib/utils/network');
|
|
48
49
|
|
|
@@ -94,7 +95,7 @@ const { registerOpenApiRoute } = require('../lib/openapi');
|
|
|
94
95
|
const { getModel: getApiReferenceModel, clearServiceUrlCache } = require('../lib/api-reference');
|
|
95
96
|
|
|
96
97
|
const { encrypt, decrypt } = require('../lib/encrypt');
|
|
97
|
-
const { Certs } = require('@postalsys/certs');
|
|
98
|
+
const { Certs, isRenewalDue } = require('@postalsys/certs');
|
|
98
99
|
const net = require('net');
|
|
99
100
|
|
|
100
101
|
const consts = require('../lib/consts');
|
|
@@ -102,7 +103,6 @@ const {
|
|
|
102
103
|
TRACK_OPEN_NOTIFY,
|
|
103
104
|
TRACK_CLICK_NOTIFY,
|
|
104
105
|
REDIS_PREFIX,
|
|
105
|
-
RENEW_TLS_AFTER,
|
|
106
106
|
BLOCK_TLS_RENEW,
|
|
107
107
|
TLS_RENEW_CHECK_INTERVAL,
|
|
108
108
|
DEFAULT_CORS_MAX_AGE,
|
|
@@ -1416,17 +1416,17 @@ const init = async () => {
|
|
|
1416
1416
|
if (USE_OIDC_AUTH) {
|
|
1417
1417
|
let redirectUrl = await getServiceRedirectUrl();
|
|
1418
1418
|
|
|
1419
|
-
//
|
|
1420
|
-
//
|
|
1421
|
-
//
|
|
1422
|
-
//
|
|
1423
|
-
//
|
|
1419
|
+
// bell needs static auth/token URLs at strategy-registration time, so the
|
|
1420
|
+
// discovery document has to be in hand before the strategy and the callback
|
|
1421
|
+
// route that depends on it can be registered. A failure to fetch it (IdP outage
|
|
1422
|
+
// or misconfig) must NOT take EmailEngine down - password and passkey login plus
|
|
1423
|
+
// the REST API have to keep working - so SSO simply stays switched off until a
|
|
1424
|
+
// later attempt succeeds.
|
|
1425
|
+
//
|
|
1426
|
+
// Assigned from enableOidc()'s return value, so it can only be set once that
|
|
1427
|
+
// strategy and route exist and validateOidcConfig() can never advertise a login
|
|
1428
|
+
// button - or trigger OIDC_FORCED - for a route that is not registered.
|
|
1424
1429
|
let oidcDiscovery = null;
|
|
1425
|
-
try {
|
|
1426
|
-
oidcDiscovery = await sso.fetchOidcDiscovery();
|
|
1427
|
-
} catch (err) {
|
|
1428
|
-
logger.error({ msg: 'OIDC SSO disabled: discovery failed', issuer: sso.OIDC_ISSUER, err });
|
|
1429
|
-
}
|
|
1430
1430
|
|
|
1431
1431
|
// Registered unconditionally so the login/security views can call it; returns
|
|
1432
1432
|
// false when discovery failed or the serviceUrl origin drifted from startup.
|
|
@@ -1448,9 +1448,9 @@ const init = async () => {
|
|
|
1448
1448
|
});
|
|
1449
1449
|
});
|
|
1450
1450
|
|
|
1451
|
-
|
|
1451
|
+
const enableOidc = async discoveryDoc => {
|
|
1452
1452
|
server.auth.strategy('oidc', 'bell', {
|
|
1453
|
-
provider: sso.buildOidcBellProvider(
|
|
1453
|
+
provider: sso.buildOidcBellProvider(discoveryDoc),
|
|
1454
1454
|
password: await settings.get('cookiePassword'),
|
|
1455
1455
|
isSecure: secureCookie,
|
|
1456
1456
|
location: redirectUrl.origin,
|
|
@@ -1514,6 +1514,32 @@ const init = async () => {
|
|
|
1514
1514
|
}
|
|
1515
1515
|
}
|
|
1516
1516
|
});
|
|
1517
|
+
|
|
1518
|
+
return discoveryDoc;
|
|
1519
|
+
};
|
|
1520
|
+
|
|
1521
|
+
let startupDoc = await sso.fetchOidcDiscovery().catch(err => {
|
|
1522
|
+
logger.error({ msg: 'OIDC SSO disabled for now: discovery failed, retrying in the background', issuer: sso.OIDC_ISSUER, err });
|
|
1523
|
+
return null;
|
|
1524
|
+
});
|
|
1525
|
+
|
|
1526
|
+
if (startupDoc) {
|
|
1527
|
+
// A registration failure here is deliberately fatal: a misconfiguration should
|
|
1528
|
+
// stop the worker at boot rather than come up quietly without SSO. The retry
|
|
1529
|
+
// path below is the opposite on purpose - it must not kill a serving process.
|
|
1530
|
+
oidcDiscovery = await enableOidc(startupDoc);
|
|
1531
|
+
} else {
|
|
1532
|
+
// Deliberately not awaited - this runs for as long as the IdP is unreachable.
|
|
1533
|
+
// hapi accepts both a new auth strategy and a new route after the server has
|
|
1534
|
+
// started, so a later success brings SSO up in place, with no restart.
|
|
1535
|
+
sso.retryDiscovery({
|
|
1536
|
+
onError: (err, attempt) => logger.debug({ msg: 'OIDC discovery retry failed', issuer: sso.OIDC_ISSUER, attempt, err })
|
|
1537
|
+
})
|
|
1538
|
+
.then(async retriedDoc => {
|
|
1539
|
+
oidcDiscovery = await enableOidc(retriedDoc);
|
|
1540
|
+
logger.info({ msg: 'OIDC SSO enabled after retrying discovery', issuer: sso.OIDC_ISSUER });
|
|
1541
|
+
})
|
|
1542
|
+
.catch(err => logger.error({ msg: 'OIDC SSO disabled: discovery retry failed', issuer: sso.OIDC_ISSUER, err }));
|
|
1517
1543
|
}
|
|
1518
1544
|
}
|
|
1519
1545
|
|
|
@@ -3319,15 +3345,27 @@ const init = async () => {
|
|
|
3319
3345
|
assertPreconditionResult = Boom.boomify(err);
|
|
3320
3346
|
}
|
|
3321
3347
|
|
|
3348
|
+
// isRenewalDue() asks whether the certificate is close enough to expiry to replace,
|
|
3349
|
+
// scaled to the lifetime the CA issued. This used to compare against
|
|
3350
|
+
// Date.now() - RENEW_TLS_AFTER, which is the expiry date thirty days in the past: it
|
|
3351
|
+
// read as "renew with thirty days left" but meant "renew thirty days after it died",
|
|
3352
|
+
// so the automatic path only ever ran once the certificate had been broken for a
|
|
3353
|
+
// month. Let's Encrypt is on the way from 90 day certificates to 45, which would have
|
|
3354
|
+
// left a service unreachable for two thirds of every certificate's life.
|
|
3322
3355
|
if (
|
|
3323
3356
|
IS_PRIMARY_API_WORKER &&
|
|
3324
3357
|
currentCert &&
|
|
3325
|
-
currentCert
|
|
3358
|
+
isRenewalDue(currentCert) &&
|
|
3326
3359
|
(!currentCert.lastCheck || currentCert.lastCheck < new Date(Date.now() - BLOCK_TLS_RENEW))
|
|
3327
3360
|
) {
|
|
3328
3361
|
try {
|
|
3329
|
-
await certHandler.acquireCert(serviceDomain);
|
|
3330
|
-
|
|
3362
|
+
let renewedCert = await certHandler.acquireCert(serviceDomain);
|
|
3363
|
+
|
|
3364
|
+
// Only when the certificate actually changed, so a renewal that was skipped
|
|
3365
|
+
// or failed does not restart both servers for nothing.
|
|
3366
|
+
if (renewedCert && renewedCert.fingerprint && renewedCert.fingerprint !== currentCert.fingerprint) {
|
|
3367
|
+
await reloadTlsServers(call, logger, { serviceDomain });
|
|
3368
|
+
}
|
|
3331
3369
|
} catch (err) {
|
|
3332
3370
|
logger.error({ msg: 'Failed to acquire TLS certificate', serviceDomain, err });
|
|
3333
3371
|
} finally {
|