emailengine-app 2.78.0 → 2.79.0
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/.ncurc.js +23 -13
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +29 -0
- package/config/e2e.toml +2 -1
- package/config/test.toml +2 -1
- package/data/google-crawlers.json +1 -1
- package/lib/account.js +70 -35
- package/lib/api-reference/format.js +91 -4
- package/lib/api-reference/model.js +144 -19
- package/lib/api-reference/schema-tree.js +282 -28
- package/lib/api-routes/account-routes.js +80 -34
- package/lib/api-routes/blocklist-routes.js +21 -47
- package/lib/api-routes/chat-routes.js +10 -12
- package/lib/api-routes/delivery-test-routes.js +6 -26
- package/lib/api-routes/export-routes.js +2 -0
- package/lib/api-routes/gateway-routes.js +52 -11
- package/lib/api-routes/license-routes.js +2 -0
- package/lib/api-routes/mailbox-routes.js +29 -26
- package/lib/api-routes/message-routes.js +27 -21
- package/lib/api-routes/oauth2-app-routes.js +11 -29
- package/lib/api-routes/operation-impact.js +80 -0
- package/lib/api-routes/outbox-routes.js +15 -5
- package/lib/api-routes/permission-map.js +397 -0
- package/lib/api-routes/route-helpers.js +223 -9
- package/lib/api-routes/route-metadata.js +28 -0
- package/lib/api-routes/settings-routes.js +30 -25
- package/lib/api-routes/stats-routes.js +2 -2
- package/lib/api-routes/submit-routes.js +53 -31
- package/lib/api-routes/template-routes.js +3 -0
- package/lib/api-routes/token-routes.js +319 -33
- package/lib/api-routes/webhook-route-routes.js +14 -4
- package/lib/auth-token.js +80 -8
- package/lib/consts.js +10 -0
- package/lib/db.js +20 -2
- package/lib/delivery-error.js +30 -1
- package/lib/email-client/base-client.js +27 -41
- package/lib/email-client/gmail-client.js +19 -10
- package/lib/email-client/imap/mailbox.js +23 -24
- package/lib/email-client/imap/subconnection.js +10 -7
- package/lib/email-client/imap/sync-operations.js +46 -46
- package/lib/email-client/imap-client.js +36 -26
- package/lib/email-client/message-builder.js +3 -3
- package/lib/email-client/notification-handler.js +1 -1
- package/lib/email-client/outlook/graph-api.js +10 -4
- package/lib/email-client/outlook-client.js +53 -54
- package/lib/email-client/smtp-pool-manager.js +1 -1
- package/lib/enum-descriptions.js +92 -2
- package/lib/export.js +1 -1
- package/lib/field-usage.js +133 -0
- package/lib/gateway.js +1 -1
- package/lib/imapproxy/imap-core/lib/commands/authenticate-plain.js +3 -3
- package/lib/imapproxy/imap-core/lib/commands/id.js +2 -13
- package/lib/imapproxy/imap-core/lib/commands/starttls.js +1 -1
- package/lib/imapproxy/imap-core/lib/imap-command.js +21 -5
- package/lib/imapproxy/imap-core/lib/imap-connection.js +15 -5
- package/lib/imapproxy/imap-server.js +27 -7
- package/lib/license-beacon.js +4 -9
- package/lib/lists.js +49 -1
- package/lib/llm-pre-process.js +5 -5
- package/lib/logger.js +5 -1
- package/lib/metrics-collector.js +2 -2
- package/lib/oauth/gmail.js +9 -12
- package/lib/oauth/mail-ru.js +5 -7
- package/lib/oauth/outlook.js +9 -9
- package/lib/oauth/pubsub/google.js +25 -10
- package/lib/oauth/scope-checker.js +1 -1
- package/lib/oauth2-apps.js +223 -294
- package/lib/openapi/build-document.js +15 -7
- package/lib/openapi/joi-schema.js +20 -0
- package/lib/outbox.js +85 -17
- package/lib/pre-process.js +8 -8
- package/lib/queue-stats.js +49 -0
- package/lib/read-env-value.js +1 -1
- package/lib/reconnection-manager.js +2 -2
- package/lib/rewrite-text-nodes.js +4 -3
- package/lib/routes-ui.js +4 -0
- package/lib/schemas.js +216 -160
- package/lib/settings.js +84 -5
- package/lib/sub-script.js +2 -1
- package/lib/swagger-options.js +2 -1
- package/lib/templates.js +4 -4
- package/lib/threads.js +2 -2
- package/lib/token-audit-log.js +208 -0
- package/lib/token-permission-view.js +219 -0
- package/lib/token-permissions.js +172 -0
- package/lib/tokens.js +99 -15
- package/lib/tools.js +142 -37
- package/lib/ui-routes/account-routes.js +31 -11
- package/lib/ui-routes/admin-config-routes.js +18 -10
- package/lib/ui-routes/admin-entities-routes.js +66 -22
- package/lib/ui-routes/auth-routes.js +30 -24
- package/lib/ui-routes/export-routes.js +10 -4
- package/lib/ui-routes/oauth-config-routes.js +5 -5
- package/lib/ui-routes/reference-routes.js +3 -3
- package/lib/ui-routes/route-helpers.js +51 -2
- package/lib/ui-routes/settings-page.js +1 -1
- package/lib/ui-routes/smtp-test-routes.js +1 -1
- package/lib/ui-routes/suppression-list-routes.js +294 -0
- package/lib/ui-routes/unsubscribe-routes.js +19 -29
- package/lib/utils/network.js +2 -2
- package/lib/web-safe-html.js +1 -1
- package/lib/webhook-routing.js +80 -0
- package/lib/webhooks.js +20 -14
- package/package.json +11 -10
- package/sbom.json +1 -1
- package/server.js +80 -41
- package/static/css/flyonui.css +1 -1
- package/static/css/src/app.tailwind.css +136 -9
- package/static/js/reference.js +456 -10
- package/static/js/ui.js +43 -0
- package/static/licenses.html +51 -41
- package/translations/messages.pot +59 -59
- package/views/accounts/account.hbs +69 -7
- package/views/accounts/browse.hbs +18 -35
- package/views/config/logging.hbs +6 -0
- package/views/config/oauth/app.hbs +0 -2
- package/views/config/security.hbs +13 -0
- package/views/partials/oauth_form.hbs +0 -15
- package/views/partials/reference/disclosure.hbs +8 -2
- package/views/partials/reference/operation.hbs +47 -13
- package/views/partials/reference/params.hbs +17 -1
- package/views/partials/reference/schema-node.hbs +110 -52
- package/views/partials/reference/schema-tools.hbs +25 -0
- package/views/partials/reference/try-it.hbs +84 -11
- package/views/partials/side_menu.hbs +1 -0
- package/views/partials/ui/checkbox.hbs +2 -2
- package/views/partials/ui/tabs.hbs +7 -1
- package/views/reference/token.hbs +4 -0
- package/views/suppression-lists/index.hbs +85 -0
- package/views/suppression-lists/list.hbs +87 -0
- package/views/templates/index.hbs +8 -2
- package/views/tokens/index.hbs +31 -4
- package/views/tokens/new.hbs +324 -2
- package/workers/api.js +146 -57
- package/workers/documents.js +46 -26
- package/workers/export.js +20 -8
- package/workers/imap-proxy.js +2 -2
- package/workers/imap.js +12 -6
- package/workers/smtp.js +13 -7
- package/workers/submit.js +40 -30
- package/workers/webhooks.js +59 -25
- package/lib/feature-flags.js +0 -48
|
@@ -43,6 +43,8 @@ const {
|
|
|
43
43
|
signedFormBlobFields: signedBlobFields
|
|
44
44
|
} = require('../schemas');
|
|
45
45
|
const { formatAccountData, cachedTemplates, identityErrorView, ACCOUNT_STATE_DISPLAY } = require('./route-helpers');
|
|
46
|
+
const { webhooks: Webhooks } = require('../webhooks');
|
|
47
|
+
const { describeEffectiveRouting } = require('../webhook-routing');
|
|
46
48
|
const { matchesExpectedIdentity, resolveExpectedIdentity } = require('../account/expected-identity');
|
|
47
49
|
|
|
48
50
|
const { REDIS_PREFIX, DEFAULT_PAGE_SIZE, NONCE_BYTES, MAX_FORM_TTL, MAX_FORM_PROBE_ATTEMPTS } = consts;
|
|
@@ -327,7 +329,7 @@ function init(args) {
|
|
|
327
329
|
}
|
|
328
330
|
|
|
329
331
|
await request.flash({ type: 'danger', message: `Failed to set up account${errors.account ? `: ${errors.account}` : ''}` });
|
|
330
|
-
request.logger.
|
|
332
|
+
request.logger.debug({ msg: 'Failed to update configuration', err });
|
|
331
333
|
|
|
332
334
|
return h.redirect('/admin/accounts').takeover();
|
|
333
335
|
},
|
|
@@ -489,7 +491,7 @@ function init(args) {
|
|
|
489
491
|
},
|
|
490
492
|
|
|
491
493
|
async failAction(request, h, err) {
|
|
492
|
-
request.logger.
|
|
494
|
+
request.logger.debug({ msg: 'Failed to validate request arguments', err });
|
|
493
495
|
let error = Boom.boomify(new Error(request.app.gt.gettext('Invalid request. Check your input and try again.')), { statusCode: 400 });
|
|
494
496
|
if (err.code) {
|
|
495
497
|
error.output.payload.code = err.code;
|
|
@@ -521,7 +523,7 @@ function init(args) {
|
|
|
521
523
|
},
|
|
522
524
|
|
|
523
525
|
async failAction(request, h, err) {
|
|
524
|
-
request.logger.
|
|
526
|
+
request.logger.debug({ msg: 'Failed to validate request arguments', err });
|
|
525
527
|
let error = Boom.boomify(new Error(request.app.gt.gettext('Invalid request. Check your input and try again.')), { statusCode: 400 });
|
|
526
528
|
if (err.code) {
|
|
527
529
|
error.output.payload.code = err.code;
|
|
@@ -737,7 +739,7 @@ function init(args) {
|
|
|
737
739
|
try {
|
|
738
740
|
serverSettings = await autodetectImapSettings(request.payload.email, request.app.gt);
|
|
739
741
|
} catch (err) {
|
|
740
|
-
request.logger.
|
|
742
|
+
request.logger.debug({ msg: 'Failed to resolve email server settings', email: request.payload.email, err });
|
|
741
743
|
}
|
|
742
744
|
|
|
743
745
|
let values = Object.assign(
|
|
@@ -801,7 +803,7 @@ function init(args) {
|
|
|
801
803
|
}
|
|
802
804
|
|
|
803
805
|
await request.flash({ type: 'danger', message: request.app.gt.gettext("Couldn't set up account. Try again.") });
|
|
804
|
-
request.logger.
|
|
806
|
+
request.logger.debug({ msg: 'Failed to process account', err });
|
|
805
807
|
|
|
806
808
|
// Repopulate the form (crucially the signed data/sig blob) from what was submitted;
|
|
807
809
|
// without it the hidden inputs render empty and the corrected re-submit fails the
|
|
@@ -1104,7 +1106,7 @@ function init(args) {
|
|
|
1104
1106
|
}
|
|
1105
1107
|
|
|
1106
1108
|
await request.flash({ type: 'danger', message: request.app.gt.gettext("Couldn't set up account. Try again.") });
|
|
1107
|
-
request.logger.
|
|
1109
|
+
request.logger.debug({ msg: 'Failed to process account', err });
|
|
1108
1110
|
|
|
1109
1111
|
// Rebuild the re-render values from the SAME schema that just validated the submission
|
|
1110
1112
|
// (coerces the tri-state checkboxes, strips unknown/prototype keys, drops both plaintext
|
|
@@ -1152,7 +1154,7 @@ function init(args) {
|
|
|
1152
1154
|
// lookup failure must never break the error re-render (failAction must not throw).
|
|
1153
1155
|
// Do NOT cache on failure - an exhausted probe cap or transient DNS error should
|
|
1154
1156
|
// not poison the hint for the whole TTL.
|
|
1155
|
-
request.logger.
|
|
1157
|
+
request.logger.debug({ msg: 'Failed to resolve app-password hint for form re-render', err });
|
|
1156
1158
|
}
|
|
1157
1159
|
}
|
|
1158
1160
|
}
|
|
@@ -1361,6 +1363,22 @@ function init(args) {
|
|
|
1361
1363
|
};
|
|
1362
1364
|
}
|
|
1363
1365
|
|
|
1366
|
+
const [webhookSettings, webhookRoutesList] = await Promise.all([
|
|
1367
|
+
settings.getMulti('webhooksEnabled', 'webhooks', 'webhookEvents', 'inboxNewOnly', 'webhooksCustomHeaders'),
|
|
1368
|
+
Webhooks.list(0, 1000)
|
|
1369
|
+
]);
|
|
1370
|
+
|
|
1371
|
+
const webhookRouting = describeEffectiveRouting({
|
|
1372
|
+
webhooksEnabled: webhookSettings.webhooksEnabled,
|
|
1373
|
+
globalWebhooks: webhookSettings.webhooks,
|
|
1374
|
+
accountWebhooks: accountData.webhooks,
|
|
1375
|
+
webhookEvents: webhookSettings.webhookEvents,
|
|
1376
|
+
inboxNewOnly: webhookSettings.inboxNewOnly,
|
|
1377
|
+
globalCustomHeaders: webhookSettings.webhooksCustomHeaders,
|
|
1378
|
+
accountCustomHeaders: accountData.webhooksCustomHeaders,
|
|
1379
|
+
routes: webhookRoutesList.webhooks
|
|
1380
|
+
});
|
|
1381
|
+
|
|
1364
1382
|
return h.view(
|
|
1365
1383
|
'accounts/account',
|
|
1366
1384
|
{
|
|
@@ -1407,7 +1425,9 @@ function init(args) {
|
|
|
1407
1425
|
t: Date.now()
|
|
1408
1426
|
}),
|
|
1409
1427
|
|
|
1410
|
-
showAdvanced: accountData.proxy || accountData.
|
|
1428
|
+
showAdvanced: accountData.proxy || accountData.path,
|
|
1429
|
+
|
|
1430
|
+
webhookRouting,
|
|
1411
1431
|
|
|
1412
1432
|
subConnectionInfo,
|
|
1413
1433
|
|
|
@@ -1457,7 +1477,7 @@ function init(args) {
|
|
|
1457
1477
|
return h.redirect('/admin/accounts');
|
|
1458
1478
|
} catch (err) {
|
|
1459
1479
|
await request.flash({ type: 'danger', message: `Couldn't delete account. Try again.` });
|
|
1460
|
-
request.logger.error({ msg: 'Failed to delete the account', err, account: request.
|
|
1480
|
+
request.logger.error({ msg: 'Failed to delete the account', err, account: request.params.account, remoteAddress: request.app.ip });
|
|
1461
1481
|
return h.redirect(`/admin/accounts/${request.params.account}`);
|
|
1462
1482
|
}
|
|
1463
1483
|
},
|
|
@@ -1489,7 +1509,7 @@ function init(args) {
|
|
|
1489
1509
|
async handler(request) {
|
|
1490
1510
|
let account = request.params.account;
|
|
1491
1511
|
try {
|
|
1492
|
-
request.logger.info({ msg: '
|
|
1512
|
+
request.logger.info({ msg: 'Requesting account reconnect', account });
|
|
1493
1513
|
try {
|
|
1494
1514
|
await call({ cmd: 'reconnect', account });
|
|
1495
1515
|
} catch (err) {
|
|
@@ -1995,7 +2015,7 @@ function init(args) {
|
|
|
1995
2015
|
}
|
|
1996
2016
|
|
|
1997
2017
|
await request.flash({ type: 'danger', message: `Couldn't save settings. Try again.` });
|
|
1998
|
-
request.logger.
|
|
2018
|
+
request.logger.debug({ msg: 'Failed to update configuration', err });
|
|
1999
2019
|
|
|
2000
2020
|
let accountObject = new Account({ redis, account: request.params.account, call, secret: await getSecret() });
|
|
2001
2021
|
let accountData = await accountObject.loadAccountData();
|
|
@@ -381,6 +381,7 @@ function init(args) {
|
|
|
381
381
|
schema: {
|
|
382
382
|
serviceSecret: settingsSchema.serviceSecret,
|
|
383
383
|
ignoreMailCertErrors: settingsSchema.ignoreMailCertErrors.default(false),
|
|
384
|
+
tokenAuditLog: settingsSchema.tokenAuditLog.default(false),
|
|
384
385
|
|
|
385
386
|
// Following options can only be changed via the UI
|
|
386
387
|
enableOAuthTokensApi: Joi.boolean()
|
|
@@ -392,13 +393,14 @@ function init(args) {
|
|
|
392
393
|
},
|
|
393
394
|
|
|
394
395
|
async loadValues() {
|
|
395
|
-
const storedValues = await settings.getMulti('serviceSecret', 'disableTokens', 'enableOAuthTokensApi', 'ignoreMailCertErrors');
|
|
396
|
+
const storedValues = await settings.getMulti('serviceSecret', 'disableTokens', 'enableOAuthTokensApi', 'ignoreMailCertErrors', 'tokenAuditLog');
|
|
396
397
|
|
|
397
398
|
return {
|
|
398
399
|
serviceSecret: storedValues.serviceSecret || null,
|
|
399
400
|
enableTokens: !storedValues.disableTokens,
|
|
400
401
|
enableOAuthTokensApi: storedValues.enableOAuthTokensApi || false,
|
|
401
|
-
ignoreMailCertErrors: storedValues.ignoreMailCertErrors || false
|
|
402
|
+
ignoreMailCertErrors: storedValues.ignoreMailCertErrors || false,
|
|
403
|
+
tokenAuditLog: storedValues.tokenAuditLog || false
|
|
402
404
|
};
|
|
403
405
|
},
|
|
404
406
|
|
|
@@ -413,7 +415,8 @@ function init(args) {
|
|
|
413
415
|
let data = {
|
|
414
416
|
disableTokens: !request.payload.enableTokens,
|
|
415
417
|
enableOAuthTokensApi: request.payload.enableOAuthTokensApi,
|
|
416
|
-
ignoreMailCertErrors: request.payload.ignoreMailCertErrors
|
|
418
|
+
ignoreMailCertErrors: request.payload.ignoreMailCertErrors,
|
|
419
|
+
tokenAuditLog: request.payload.tokenAuditLog
|
|
417
420
|
};
|
|
418
421
|
|
|
419
422
|
// Only overwrite the service secret when a non-empty value is provided: an empty
|
|
@@ -767,7 +770,7 @@ return true;`
|
|
|
767
770
|
|
|
768
771
|
return { success: true, models };
|
|
769
772
|
} catch (err) {
|
|
770
|
-
request.logger.
|
|
773
|
+
request.logger.warn({ msg: 'Failed to reload OpenAI models', err });
|
|
771
774
|
return {
|
|
772
775
|
success: false,
|
|
773
776
|
error: err.message
|
|
@@ -817,7 +820,7 @@ return true;`
|
|
|
817
820
|
},
|
|
818
821
|
|
|
819
822
|
async failAction(request, h, err) {
|
|
820
|
-
request.logger.
|
|
823
|
+
request.logger.debug({ msg: 'Failed to process preview', err });
|
|
821
824
|
return h.redirect('/admin').takeover();
|
|
822
825
|
},
|
|
823
826
|
|
|
@@ -932,7 +935,10 @@ return true;`
|
|
|
932
935
|
// checkbox must render as checked regardless of the stored setting - also on
|
|
933
936
|
// error re-renders, where the disabled (unsubmitted) field is absent from
|
|
934
937
|
// the payload
|
|
935
|
-
sentryChecked: sentryEnvManaged || !!values.sentryEnabled
|
|
938
|
+
sentryChecked: sentryEnvManaged || !!values.sentryEnabled,
|
|
939
|
+
// reporting was turned on by trial activation, not by the operator; disclosed
|
|
940
|
+
// on the page because saving the form converts it into an explicit choice
|
|
941
|
+
sentryTrialManaged: !sentryEnvManaged && !!(await settings.get('sentryAutoEnabled'))
|
|
936
942
|
};
|
|
937
943
|
},
|
|
938
944
|
|
|
@@ -1100,7 +1106,9 @@ return true;`
|
|
|
1100
1106
|
duration
|
|
1101
1107
|
};
|
|
1102
1108
|
} catch (err) {
|
|
1103
|
-
|
|
1109
|
+
// log the parsed URL, not the raw payload value, so embedded basic-auth credentials
|
|
1110
|
+
// stay out of the log
|
|
1111
|
+
request.logger.warn({ msg: 'Failed to post test webhook', webhooks: parsed.toString(), event: 'test', err });
|
|
1104
1112
|
return {
|
|
1105
1113
|
success: false,
|
|
1106
1114
|
target: webhooks,
|
|
@@ -1207,7 +1215,7 @@ return true;`
|
|
|
1207
1215
|
return h.redirect('/admin/config/license');
|
|
1208
1216
|
} catch (err) {
|
|
1209
1217
|
await request.flash({ type: 'danger', message: `Couldn't register license. Check the key and try again.` });
|
|
1210
|
-
request.logger.
|
|
1218
|
+
request.logger.warn({ msg: 'Failed to register license key', err });
|
|
1211
1219
|
|
|
1212
1220
|
return h.view(
|
|
1213
1221
|
'config/license',
|
|
@@ -1249,7 +1257,7 @@ return true;`
|
|
|
1249
1257
|
}
|
|
1250
1258
|
|
|
1251
1259
|
await request.flash({ type: 'danger', message: `Couldn't register license. Check the key and try again.` });
|
|
1252
|
-
request.logger.
|
|
1260
|
+
request.logger.warn({ msg: 'Failed to register license key', err });
|
|
1253
1261
|
|
|
1254
1262
|
return h
|
|
1255
1263
|
.view(
|
|
@@ -1302,7 +1310,7 @@ return true;`
|
|
|
1302
1310
|
return h.redirect('/admin/config/license');
|
|
1303
1311
|
} catch (err) {
|
|
1304
1312
|
await request.flash({ type: 'danger', message: `Couldn't remove license. Try again.` });
|
|
1305
|
-
request.logger.error({ msg: 'Failed to unregister license key', err,
|
|
1313
|
+
request.logger.error({ msg: 'Failed to unregister license key', err, remoteAddress: request.app.ip });
|
|
1306
1314
|
return h.redirect('/admin/config/license');
|
|
1307
1315
|
}
|
|
1308
1316
|
},
|
|
@@ -7,14 +7,16 @@ const settings = require('../settings');
|
|
|
7
7
|
const tokens = require('../tokens');
|
|
8
8
|
const { redis } = require('../db');
|
|
9
9
|
const getSecret = require('../get-secret');
|
|
10
|
-
const { failAction, verifyAccountInfo } = require('../tools');
|
|
11
|
-
const { templateSchemas, accountIdSchema } = require('../schemas');
|
|
10
|
+
const { failAction, verifyAccountInfo, formatPartialSecretKey } = require('../tools');
|
|
11
|
+
const { templateSchemas, accountIdSchema, tokenPermissionsSchema } = require('../schemas');
|
|
12
|
+
const tokenPermissionView = require('../token-permission-view');
|
|
12
13
|
const { Account } = require('../account');
|
|
13
14
|
const { Gateway } = require('../gateway');
|
|
14
15
|
const { templates } = require('../templates');
|
|
15
16
|
const { webhooks } = require('../webhooks');
|
|
16
17
|
const consts = require('../consts');
|
|
17
18
|
const wellKnownServices = require('nodemailer/lib/well-known/services.json');
|
|
19
|
+
const { authAwareLevel } = require('./route-helpers');
|
|
18
20
|
const exampleWebhookPayloads = require('../payload-examples-webhooks.json');
|
|
19
21
|
|
|
20
22
|
const { DEFAULT_PAGE_SIZE } = consts;
|
|
@@ -301,7 +303,7 @@ return payload;`)
|
|
|
301
303
|
return h.redirect(`/admin/webhooks/webhook/${createRequest.id}`);
|
|
302
304
|
} catch (err) {
|
|
303
305
|
await request.flash({ type: 'danger', message: `Couldn't create webhook. Try again.` });
|
|
304
|
-
request.logger.error({ msg: 'Failed to create webhook
|
|
306
|
+
request.logger.error({ msg: 'Failed to create webhook route', err });
|
|
305
307
|
|
|
306
308
|
return h.view(
|
|
307
309
|
'webhooks/new',
|
|
@@ -340,7 +342,7 @@ return payload;`)
|
|
|
340
342
|
}
|
|
341
343
|
|
|
342
344
|
await request.flash({ type: 'danger', message: `Couldn't create webhook. Try again.` });
|
|
343
|
-
request.logger.
|
|
345
|
+
request.logger.debug({ msg: 'Failed to create webhook route', err });
|
|
344
346
|
|
|
345
347
|
return h
|
|
346
348
|
.view(
|
|
@@ -613,7 +615,7 @@ return payload;`)
|
|
|
613
615
|
return h.redirect(`/admin/webhooks/webhook/${request.payload.webhook}`);
|
|
614
616
|
} catch (err) {
|
|
615
617
|
await request.flash({ type: 'danger', message: `Couldn't save webhook. Try again.` });
|
|
616
|
-
request.logger.error({ msg: 'Failed to update
|
|
618
|
+
request.logger.error({ msg: 'Failed to update webhook route', err });
|
|
617
619
|
|
|
618
620
|
let webhook = await webhooks.get(request.payload.webhook);
|
|
619
621
|
if (!webhook) {
|
|
@@ -661,7 +663,7 @@ return payload;`)
|
|
|
661
663
|
}
|
|
662
664
|
|
|
663
665
|
await request.flash({ type: 'danger', message: `Couldn't save webhook. Try again.` });
|
|
664
|
-
request.logger.
|
|
666
|
+
request.logger.debug({ msg: 'Failed to update webhook route', err });
|
|
665
667
|
|
|
666
668
|
let webhook = await webhooks.get(request.payload.webhook);
|
|
667
669
|
if (!webhook) {
|
|
@@ -757,7 +759,7 @@ return payload;`)
|
|
|
757
759
|
return h.redirect(accountWebhooksLink.pathname + accountWebhooksLink.search);
|
|
758
760
|
} catch (err) {
|
|
759
761
|
await request.flash({ type: 'danger', message: `Couldn't delete webhook. Try again.` });
|
|
760
|
-
request.logger.error({ msg: 'Failed to delete
|
|
762
|
+
request.logger.error({ msg: 'Failed to delete webhook route', err, webhook: request.payload.webhook, remoteAddress: request.app.ip });
|
|
761
763
|
return h.redirect(`/admin/webhooks/webhook/${request.payload.webhook}`);
|
|
762
764
|
}
|
|
763
765
|
},
|
|
@@ -771,7 +773,7 @@ return payload;`)
|
|
|
771
773
|
|
|
772
774
|
async failAction(request, h, err) {
|
|
773
775
|
await request.flash({ type: 'danger', message: `Couldn't delete webhook. Try again.` });
|
|
774
|
-
request.logger.
|
|
776
|
+
request.logger.debug({ msg: 'Failed to delete webhook route', err });
|
|
775
777
|
|
|
776
778
|
return h.redirect('/admin/webhooks').takeover();
|
|
777
779
|
},
|
|
@@ -1123,7 +1125,7 @@ return payload;`)
|
|
|
1123
1125
|
}
|
|
1124
1126
|
|
|
1125
1127
|
await request.flash({ type: 'danger', message: `Couldn't save template. Try again.` });
|
|
1126
|
-
request.logger.
|
|
1128
|
+
request.logger.debug({ msg: 'Failed to update template', err });
|
|
1127
1129
|
|
|
1128
1130
|
let template = await templates.get(request.payload.template);
|
|
1129
1131
|
if (!template) {
|
|
@@ -1342,7 +1344,7 @@ return payload;`)
|
|
|
1342
1344
|
}
|
|
1343
1345
|
|
|
1344
1346
|
await request.flash({ type: 'danger', message: `Couldn't create template. Try again.` });
|
|
1345
|
-
request.logger.
|
|
1347
|
+
request.logger.debug({ msg: 'Failed to create template', err });
|
|
1346
1348
|
|
|
1347
1349
|
let account;
|
|
1348
1350
|
if (request.payload.account) {
|
|
@@ -1430,8 +1432,8 @@ return payload;`)
|
|
|
1430
1432
|
},
|
|
1431
1433
|
|
|
1432
1434
|
async failAction(request, h, err) {
|
|
1433
|
-
await request.flash({ type: 'danger', message: `Couldn't delete
|
|
1434
|
-
request.logger.error({ msg: 'Failed to delete the
|
|
1435
|
+
await request.flash({ type: 'danger', message: `Couldn't delete template. Try again.` });
|
|
1436
|
+
request.logger.error({ msg: 'Failed to delete the template', err });
|
|
1435
1437
|
|
|
1436
1438
|
return h.redirect('/admin/templates').takeover();
|
|
1437
1439
|
},
|
|
@@ -1453,7 +1455,12 @@ return payload;`)
|
|
|
1453
1455
|
path: '/admin/templates/test',
|
|
1454
1456
|
async handler(request) {
|
|
1455
1457
|
try {
|
|
1456
|
-
request.logger.
|
|
1458
|
+
request.logger.debug({
|
|
1459
|
+
msg: 'Trying to send test message',
|
|
1460
|
+
template: request.payload.template,
|
|
1461
|
+
account: request.payload.account,
|
|
1462
|
+
to: request.payload.to
|
|
1463
|
+
});
|
|
1457
1464
|
|
|
1458
1465
|
let template = await templates.get(request.payload.template);
|
|
1459
1466
|
if (!template) {
|
|
@@ -1502,7 +1509,7 @@ return payload;`)
|
|
|
1502
1509
|
};
|
|
1503
1510
|
}
|
|
1504
1511
|
} catch (err) {
|
|
1505
|
-
request.logger.error({ msg: 'Failed
|
|
1512
|
+
request.logger.error({ msg: 'Failed to send test message', err });
|
|
1506
1513
|
return {
|
|
1507
1514
|
success: false,
|
|
1508
1515
|
error: err.message
|
|
@@ -1824,7 +1831,7 @@ return payload;`)
|
|
|
1824
1831
|
}
|
|
1825
1832
|
|
|
1826
1833
|
await request.flash({ type: 'danger', message: `Couldn't add gateway. Try again.` });
|
|
1827
|
-
request.logger.
|
|
1834
|
+
request.logger.debug({ msg: 'Failed to add new gateway', err });
|
|
1828
1835
|
|
|
1829
1836
|
return h
|
|
1830
1837
|
.view(
|
|
@@ -1946,7 +1953,7 @@ return payload;`)
|
|
|
1946
1953
|
}
|
|
1947
1954
|
|
|
1948
1955
|
await request.flash({ type: 'danger', message: `Couldn't save gateway. Try again.` });
|
|
1949
|
-
request.logger.
|
|
1956
|
+
request.logger.debug({ msg: 'Failed to update gateway', err });
|
|
1950
1957
|
|
|
1951
1958
|
let gatewayObject = new Gateway({ gateway: request.payload.gateway, redis, secret: await getSecret() });
|
|
1952
1959
|
let gatewayData = await gatewayObject.loadGatewayData();
|
|
@@ -2076,7 +2083,7 @@ return payload;`)
|
|
|
2076
2083
|
|
|
2077
2084
|
return verifyResult.smtp;
|
|
2078
2085
|
} catch (err) {
|
|
2079
|
-
request.logger.error({ msg: 'Failed
|
|
2086
|
+
request.logger.error({ msg: 'Failed to verify gateway SMTP settings', host, port, user, pass: !!pass, err });
|
|
2080
2087
|
return {
|
|
2081
2088
|
success: false,
|
|
2082
2089
|
error: err.message
|
|
@@ -2133,7 +2140,7 @@ return payload;`)
|
|
|
2133
2140
|
return h.redirect('/admin/gateways');
|
|
2134
2141
|
} catch (err) {
|
|
2135
2142
|
await request.flash({ type: 'danger', message: `Couldn't delete gateway. Try again.` });
|
|
2136
|
-
request.logger.error({ msg: 'Failed to delete the gateway', err, gateway: request.
|
|
2143
|
+
request.logger.error({ msg: 'Failed to delete the gateway', err, gateway: request.params.gateway, remoteAddress: request.app.ip });
|
|
2137
2144
|
return h.redirect(`/admin/gateways/${request.params.gateway}`);
|
|
2138
2145
|
}
|
|
2139
2146
|
},
|
|
@@ -2147,7 +2154,7 @@ return payload;`)
|
|
|
2147
2154
|
|
|
2148
2155
|
async failAction(request, h, err) {
|
|
2149
2156
|
await request.flash({ type: 'danger', message: `Couldn't delete gateway. Try again.` });
|
|
2150
|
-
request.logger.
|
|
2157
|
+
request.logger.debug({ msg: 'Failed to delete the gateway', err });
|
|
2151
2158
|
|
|
2152
2159
|
return h.redirect('/admin/gateways').takeover();
|
|
2153
2160
|
},
|
|
@@ -2187,6 +2194,9 @@ return payload;`)
|
|
|
2187
2194
|
first: !i
|
|
2188
2195
|
}))
|
|
2189
2196
|
: false;
|
|
2197
|
+
// A narrowed token looks identical to a full one in a list that only shows scopes,
|
|
2198
|
+
// which is the opposite of what the narrowing is for
|
|
2199
|
+
entry.permissionSummary = tokenPermissionView.summarize(entry.permissions);
|
|
2190
2200
|
});
|
|
2191
2201
|
|
|
2192
2202
|
let nextPage = false;
|
|
@@ -2237,6 +2247,8 @@ return payload;`)
|
|
|
2237
2247
|
searchTarget: '/admin/tokens',
|
|
2238
2248
|
searchPlaceholder: 'Search for access tokens…',
|
|
2239
2249
|
query: request.query.query,
|
|
2250
|
+
// The create button leads to a form that cannot submit without an admin session
|
|
2251
|
+
canProvision: request.auth.isAuthenticated,
|
|
2240
2252
|
searchHidden: request.query.account ? [{ name: 'account', value: request.query.account }] : null,
|
|
2241
2253
|
total: data.total,
|
|
2242
2254
|
|
|
@@ -2295,6 +2307,8 @@ return payload;`)
|
|
|
2295
2307
|
accountTokensLink.searchParams.append('account', request.query.account);
|
|
2296
2308
|
}
|
|
2297
2309
|
|
|
2310
|
+
const permissionModel = tokenPermissionView.formModel();
|
|
2311
|
+
|
|
2298
2312
|
return h.view(
|
|
2299
2313
|
'tokens/new',
|
|
2300
2314
|
{
|
|
@@ -2305,6 +2319,15 @@ return payload;`)
|
|
|
2305
2319
|
allAccounts: !request.query.account,
|
|
2306
2320
|
account: request.query.account
|
|
2307
2321
|
},
|
|
2322
|
+
// Same expression the POST gate uses, so the form and the thing it submits to
|
|
2323
|
+
// cannot disagree. A token is never invalidated once minted, so one handed to a
|
|
2324
|
+
// caller that reached this page without authenticating would keep working - which
|
|
2325
|
+
// is why the mint is refused rather than merely discouraged. Rendering the form
|
|
2326
|
+
// anyway meant filling it in and losing the work to a 403.
|
|
2327
|
+
canProvision: request.auth.isAuthenticated,
|
|
2328
|
+
...permissionModel,
|
|
2329
|
+
// Handed to the page as data rather than restated in its script
|
|
2330
|
+
permissionSurfacesJson: JSON.stringify(permissionModel.permissionSurfaces),
|
|
2308
2331
|
account: accountData,
|
|
2309
2332
|
accountTokensLink: accountTokensLink.pathname + accountTokensLink.search
|
|
2310
2333
|
},
|
|
@@ -2359,6 +2382,12 @@ return payload;`)
|
|
|
2359
2382
|
scopes: request.payload.scopes
|
|
2360
2383
|
};
|
|
2361
2384
|
|
|
2385
|
+
if (request.payload.permissions) {
|
|
2386
|
+
// An axis that lists nothing is refused by tokenPermissionsSchema, so both mint
|
|
2387
|
+
// paths give the same answer rather than this one carrying its own copy of the rule
|
|
2388
|
+
data.permissions = request.payload.permissions;
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2362
2391
|
if (request.payload.account) {
|
|
2363
2392
|
let accountObject = new Account({ redis, account: request.payload.account });
|
|
2364
2393
|
await accountObject.loadAccountData();
|
|
@@ -2372,7 +2401,12 @@ return payload;`)
|
|
|
2372
2401
|
token
|
|
2373
2402
|
};
|
|
2374
2403
|
} catch (err) {
|
|
2375
|
-
request.logger
|
|
2404
|
+
request.logger[authAwareLevel(err)]({
|
|
2405
|
+
msg: 'Failed to generate token',
|
|
2406
|
+
err,
|
|
2407
|
+
remoteAddress: request.app.ip,
|
|
2408
|
+
description: request.payload.description
|
|
2409
|
+
});
|
|
2376
2410
|
if (Boom.isBoom(err)) {
|
|
2377
2411
|
return Object.assign({ success: false }, err.output.payload);
|
|
2378
2412
|
}
|
|
@@ -2395,6 +2429,9 @@ return payload;`)
|
|
|
2395
2429
|
.items(Joi.string().valid('*', 'api', 'metrics', 'smtp', 'imap-proxy'))
|
|
2396
2430
|
.required()
|
|
2397
2431
|
.label('Scopes'),
|
|
2432
|
+
// Null when the restriction is off, which is what "not narrowed" means on the
|
|
2433
|
+
// record - distinct from an empty object, which tokenPermissionsSchema refuses
|
|
2434
|
+
permissions: tokenPermissionsSchema.default(null),
|
|
2398
2435
|
account: accountIdSchema.default(null)
|
|
2399
2436
|
})
|
|
2400
2437
|
}
|
|
@@ -2414,7 +2451,14 @@ return payload;`)
|
|
|
2414
2451
|
return h.redirect('/admin/tokens');
|
|
2415
2452
|
} catch (err) {
|
|
2416
2453
|
await request.flash({ type: 'danger', message: `Couldn't delete token. Try again.` });
|
|
2417
|
-
|
|
2454
|
+
// Only log a partial value: the payload is usually a token id, but it can also be a
|
|
2455
|
+
// raw access token, which must never land in the log whole
|
|
2456
|
+
request.logger.error({
|
|
2457
|
+
msg: 'Failed to delete access token',
|
|
2458
|
+
err,
|
|
2459
|
+
token: request.payload.token ? formatPartialSecretKey(request.payload.token) : null,
|
|
2460
|
+
remoteAddress: request.app.ip
|
|
2461
|
+
});
|
|
2418
2462
|
return h.redirect('/admin/tokens');
|
|
2419
2463
|
}
|
|
2420
2464
|
},
|
|
@@ -2428,7 +2472,7 @@ return payload;`)
|
|
|
2428
2472
|
|
|
2429
2473
|
async failAction(request, h, err) {
|
|
2430
2474
|
await request.flash({ type: 'danger', message: `Couldn't delete token. Try again.` });
|
|
2431
|
-
request.logger.
|
|
2475
|
+
request.logger.debug({ msg: 'Failed to delete access token', err });
|
|
2432
2476
|
|
|
2433
2477
|
return h.redirect('/admin/tokens').takeover();
|
|
2434
2478
|
},
|