emailengine-app 2.79.0 → 2.79.1
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 +39 -0
- package/lib/account.js +43 -2
- package/lib/api-routes/permission-map.js +4 -0
- package/lib/api-routes/route-helpers.js +71 -0
- package/lib/api-routes/settings-routes.js +37 -14
- package/lib/api-routes/token-routes.js +290 -122
- package/lib/arf-detect.js +17 -4
- package/lib/bounce-detect.js +28 -17
- package/lib/consts.js +6 -0
- package/lib/db.js +6 -0
- package/lib/email-client/gmail-client.js +4 -7
- package/lib/email-client/imap/mailbox.js +35 -35
- package/lib/email-client/imap-client.js +49 -2
- package/lib/email-client/outlook-client.js +3 -10
- package/lib/lua/h-set-new-mark.lua +36 -0
- package/lib/message-port-stream.js +84 -1
- package/lib/oauth2-apps.js +84 -15
- package/lib/openapi/build-document.js +5 -1
- package/lib/schemas.js +2 -2
- package/lib/settings.js +23 -9
- package/lib/token-audit-log.js +32 -9
- package/lib/tokens.js +163 -66
- package/lib/ui-routes/account-routes.js +13 -6
- package/lib/ui-routes/admin-entities-routes.js +52 -17
- package/lib/ui-routes/oauth-config-routes.js +7 -7
- package/lib/ui-routes/route-helpers.js +28 -1
- package/lib/ui-routes/suppression-list-routes.js +14 -9
- package/lib/utils/decode-headers.js +42 -0
- package/lib/utils/header-map.js +48 -0
- package/lib/utils/unsafe-key.js +59 -0
- package/lib/webhook-routing.js +6 -2
- package/lib/webhooks.js +28 -0
- package/package.json +1 -1
- package/server.js +39 -17
- package/views/accounts/account.hbs +8 -8
- package/views/accounts/browse.hbs +1 -1
- package/views/accounts/edit.hbs +2 -2
- package/views/gateways/edit.hbs +1 -1
- package/views/gateways/gateway.hbs +2 -2
- package/views/gateways/index.hbs +7 -7
- package/views/partials/accounts_table.hbs +7 -7
- package/views/suppression-lists/list.hbs +1 -1
- package/views/templates/index.hbs +2 -2
- package/views/templates/template.hbs +1 -1
- package/views/tokens/index.hbs +22 -2
- package/views/tokens/new.hbs +10 -3
- package/workers/api.js +41 -47
- package/workers/imap.js +65 -72
- package/workers/webhooks.js +21 -1
package/server.js
CHANGED
|
@@ -115,6 +115,7 @@ initSentry('main');
|
|
|
115
115
|
// Import additional dependencies
|
|
116
116
|
const pathlib = require('path');
|
|
117
117
|
const { redis, queueConf, notifyQueue, submitQueue, documentsQueue, exportQueue } = require('./lib/db');
|
|
118
|
+
const { queueStats } = require('./lib/queue-stats');
|
|
118
119
|
const { packRpcError, unpackRpcError } = require('./lib/worker-rpc-error');
|
|
119
120
|
const promClient = require('prom-client');
|
|
120
121
|
const fs = require('fs').promises;
|
|
@@ -446,7 +447,9 @@ const preparedSettingsString = readEnvValue('EENGINE_SETTINGS') || config.settin
|
|
|
446
447
|
if (preparedSettingsString) {
|
|
447
448
|
// Parse and validate pre-configured settings
|
|
448
449
|
try {
|
|
449
|
-
const
|
|
450
|
+
const parsedSettings = JSON.parse(preparedSettingsString);
|
|
451
|
+
|
|
452
|
+
const { error, value } = Joi.object(settingsSchema).validate(parsedSettings, {
|
|
450
453
|
abortEarly: false,
|
|
451
454
|
stripUnknown: true,
|
|
452
455
|
convert: true
|
|
@@ -456,6 +459,22 @@ if (preparedSettingsString) {
|
|
|
456
459
|
throw error;
|
|
457
460
|
}
|
|
458
461
|
|
|
462
|
+
// stripUnknown drops unknown keys without an error, which silently swallows both typos
|
|
463
|
+
// and keys that used to be settings - most notably the legacy gmail*/outlook*/mailRu*
|
|
464
|
+
// OAuth2 keys that moved into the OAuth2 app registry. Booting on regardless is right
|
|
465
|
+
// (an upgraded install must not be bricked by a stale env variable), but the drop has
|
|
466
|
+
// to be visible: for the legacy keys the operator has to create an OAuth2 app instead,
|
|
467
|
+
// because nothing reads these values anymore.
|
|
468
|
+
if (parsedSettings && typeof parsedSettings === 'object') {
|
|
469
|
+
const droppedKeys = Object.keys(parsedSettings).filter(key => !Object.hasOwn(settingsSchema, key));
|
|
470
|
+
if (droppedKeys.length) {
|
|
471
|
+
logger.error({
|
|
472
|
+
msg: 'Ignoring unknown keys in the prepared settings. Settings-based OAuth2 configuration is not supported anymore - use an OAuth2 app instead',
|
|
473
|
+
keys: droppedKeys
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
459
478
|
preparedSettings = value;
|
|
460
479
|
} catch (err) {
|
|
461
480
|
// A joi failure here carries every submitted setting - including smtpServerPassword,
|
|
@@ -2248,25 +2267,28 @@ async function updateQueueCounters() {
|
|
|
2248
2267
|
// Set unresponsive workers metric
|
|
2249
2268
|
metrics.unresponsiveWorkers.set(unresponsiveCount);
|
|
2250
2269
|
|
|
2251
|
-
// Update queue metrics
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2270
|
+
// Update queue metrics through BullMQ's own API (lib/queue-stats.js). Counting raw
|
|
2271
|
+
// llen/zcard against BullMQ's private key layout broke silently in the 5.x -> 6.x bump: the
|
|
2272
|
+
// `:paused` list no longer exists (a paused queue holds its jobs in `wait`), and a leftover
|
|
2273
|
+
// `0:` wait-list marker from a 5.x install counts as a phantom waiting job. The `paused`
|
|
2274
|
+
// gauge is kept at the 0 the getter reports so existing dashboards keep their series.
|
|
2275
|
+
for (let [queue, queueObj] of [
|
|
2276
|
+
['notify', notifyQueue],
|
|
2277
|
+
['submit', submitQueue],
|
|
2278
|
+
['documents', documentsQueue]
|
|
2279
|
+
]) {
|
|
2280
|
+
let stats;
|
|
2281
|
+
try {
|
|
2282
|
+
stats = await queueStats(queueObj);
|
|
2283
|
+
} catch (err) {
|
|
2284
|
+
logger.error({ msg: 'Queue length count failed', queue, err });
|
|
2263
2285
|
return false;
|
|
2264
2286
|
}
|
|
2265
2287
|
|
|
2266
|
-
metrics.queues.set({ queue: `${queue}`, state: `active` },
|
|
2267
|
-
metrics.queues.set({ queue: `${queue}`, state: `delayed` },
|
|
2268
|
-
metrics.queues.set({ queue: `${queue}`, state: `paused` },
|
|
2269
|
-
metrics.queues.set({ queue: `${queue}`, state: `waiting` },
|
|
2288
|
+
metrics.queues.set({ queue: `${queue}`, state: `active` }, stats.active);
|
|
2289
|
+
metrics.queues.set({ queue: `${queue}`, state: `delayed` }, stats.delayed);
|
|
2290
|
+
metrics.queues.set({ queue: `${queue}`, state: `paused` }, stats.paused);
|
|
2291
|
+
metrics.queues.set({ queue: `${queue}`, state: `waiting` }, stats.waiting);
|
|
2270
2292
|
}
|
|
2271
2293
|
|
|
2272
2294
|
// Update Redis metrics
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
{{!-- Primary: the two most common reasons to open an account --}}
|
|
19
19
|
{{#if canReadMail}}
|
|
20
20
|
{{#> ui/tooltip text="Browse messages in this account"}}
|
|
21
|
-
{{> ui/btn variant="primary" size="sm" href=(concat "/admin/accounts/" account.account "/browse") icon="icon-[tabler--folder-open]" label="Browse messages"}}
|
|
21
|
+
{{> ui/btn variant="primary" size="sm" href=(concat "/admin/accounts/" (urlpart account.account) "/browse") icon="icon-[tabler--folder-open]" label="Browse messages"}}
|
|
22
22
|
{{/ui/tooltip}}
|
|
23
23
|
{{/if}}
|
|
24
24
|
|
|
25
25
|
{{#> ui/tooltip text="Edit account configuration"}}
|
|
26
|
-
{{> ui/btn variant="primary" style="outline" size="sm" href=(concat "/admin/accounts/" account.account "/edit") icon="icon-[tabler--user-edit]" label="Edit"}}
|
|
26
|
+
{{> ui/btn variant="primary" style="outline" size="sm" href=(concat "/admin/accounts/" (urlpart account.account) "/edit") icon="icon-[tabler--user-edit]" label="Edit"}}
|
|
27
27
|
{{/ui/tooltip}}
|
|
28
28
|
|
|
29
29
|
<div class="bg-base-content/10 mx-1 hidden h-6 w-px self-center sm:block" aria-hidden="true"></div>
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
</button>
|
|
106
106
|
<ul class="dropdown-menu dropdown-open:opacity-100 hidden min-w-56" role="menu"
|
|
107
107
|
aria-orientation="vertical" aria-labelledby="logs-info">
|
|
108
|
-
<li><a class="dropdown-item" href="/admin/accounts/{{account.account}}/logs.txt" download>Download stored logs</a></li>
|
|
108
|
+
<li><a class="dropdown-item" href="/admin/accounts/{{urlpart account.account}}/logs.txt" download>Download stored logs</a></li>
|
|
109
109
|
<li>
|
|
110
110
|
<div class="divider my-1"></div>
|
|
111
111
|
</li>
|
|
@@ -125,9 +125,9 @@
|
|
|
125
125
|
{{!-- Related resources scoped to this account (these navigate elsewhere) --}}
|
|
126
126
|
<div class="mb-4 text-base-content/60 text-sm">
|
|
127
127
|
<span class="font-semibold">Related:</span>
|
|
128
|
-
<a class="link link-animated" href="/admin/templates/?account={{account.account}}">Email templates</a>
|
|
128
|
+
<a class="link link-animated" href="/admin/templates/?account={{urlpart account.account}}">Email templates</a>
|
|
129
129
|
<span class="text-base-content/30 mx-1">·</span>
|
|
130
|
-
<a class="link link-animated" href="/admin/tokens/?account={{account.account}}">Access tokens</a>
|
|
130
|
+
<a class="link link-animated" href="/admin/tokens/?account={{urlpart account.account}}">Access tokens</a>
|
|
131
131
|
</div>
|
|
132
132
|
|
|
133
133
|
<dl class="ee-dl">
|
|
@@ -747,10 +747,10 @@
|
|
|
747
747
|
{{#if webhookRouting.customRoutes.length}}
|
|
748
748
|
<ul class="list-none p-0 m-0">
|
|
749
749
|
{{#each webhookRouting.customRoutes}}
|
|
750
|
-
<li><a href="/admin/webhooks/webhook/{{this.id}}" class="link link-primary">{{this.name}}</a> <code class="text-base-content/60">{{this.targetUrl}}</code
|
|
750
|
+
<li><a href="/admin/webhooks/webhook/{{this.id}}" class="link link-primary">{{this.name}}</a> <code class="text-base-content/60">{{this.targetUrl}}</code>{{#if this.missingFilter}} {{> ui/badge label="no filter - never delivers" variant="warning" soft=true}}{{/if}}</li>
|
|
751
751
|
{{/each}}
|
|
752
752
|
</ul>
|
|
753
|
-
<small class="text-base-content/60">Enabled webhook routes deliver independently of the default target; each route applies its own filter function instead of the event type list.</small>
|
|
753
|
+
<small class="text-base-content/60">Enabled webhook routes deliver independently of the default target; each route applies its own filter function instead of the event type list. A route without a filter function never delivers anything.</small>
|
|
754
754
|
{{else}}
|
|
755
755
|
<span class="text-base-content/60">None enabled</span>
|
|
756
756
|
{{/if}}
|
|
@@ -792,7 +792,7 @@
|
|
|
792
792
|
</div>
|
|
793
793
|
{{/ui/modal}}
|
|
794
794
|
|
|
795
|
-
{{#> ui/confirm-modal id="deleteModal" title="Delete Account" action=(concat "/admin/accounts/" account.account "/delete")
|
|
795
|
+
{{#> ui/confirm-modal id="deleteModal" title="Delete Account" action=(concat "/admin/accounts/" (urlpart account.account) "/delete")
|
|
796
796
|
submitLabel="Delete account"}}
|
|
797
797
|
<p>Are you sure you want to delete the account for {{account.name}}? This action cannot be undone.</p>
|
|
798
798
|
{{/ui/confirm-modal}}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{{> accounts_header}}
|
|
2
2
|
|
|
3
|
-
{{> ui/breadcrumb parentHref="/admin/accounts" parentLabel="Accounts" midHref=(concat "/admin/accounts/" account) midLabel=account current="Browse" class="mt-6 mb-6"}}
|
|
3
|
+
{{> ui/breadcrumb parentHref="/admin/accounts" parentLabel="Accounts" midHref=(concat "/admin/accounts/" (urlpart account)) midLabel=account current="Browse" class="mt-6 mb-6"}}
|
|
4
4
|
|
|
5
5
|
<div id="email-client"></div>
|
|
6
6
|
|
package/views/accounts/edit.hbs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{{> accounts_header}}
|
|
2
2
|
|
|
3
|
-
{{> ui/breadcrumb parentHref="/admin/accounts" parentLabel="Accounts" midHref=(concat "/admin/accounts/" account) midLabel=account current="Edit" class="mt-6 mb-6"}}
|
|
3
|
+
{{> ui/breadcrumb parentHref="/admin/accounts" parentLabel="Accounts" midHref=(concat "/admin/accounts/" (urlpart account)) midLabel=account current="Edit" class="mt-6 mb-6"}}
|
|
4
4
|
|
|
5
|
-
<form method="post" action="/admin/accounts/{{account}}/edit">
|
|
5
|
+
<form method="post" action="/admin/accounts/{{urlpart account}}/edit">
|
|
6
6
|
<input type="hidden" name="crumb" value="{{crumb}}">
|
|
7
7
|
|
|
8
8
|
<div class="card bg-base-100 shadow-md mb-6">
|
package/views/gateways/edit.hbs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{{> gateways_header}}
|
|
2
2
|
|
|
3
|
-
{{> ui/breadcrumb parentHref="/admin/gateways" parentLabel="Gateways" midHref=(concat "/admin/gateways/gateway/" gatewayData.gateway) midLabel=gatewayData.gateway current="Edit" class="mt-6 mb-6"}}
|
|
3
|
+
{{> ui/breadcrumb parentHref="/admin/gateways" parentLabel="Gateways" midHref=(concat "/admin/gateways/gateway/" (urlpart gatewayData.gateway)) midLabel=gatewayData.gateway current="Edit" class="mt-6 mb-6"}}
|
|
4
4
|
|
|
5
5
|
<form method="post" action="/admin/gateways/edit">
|
|
6
6
|
<input type="hidden" name="crumb" value="{{crumb}}">
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
{{#> ui/detail-toolbar label="Gateway actions"}}
|
|
17
17
|
{{#> ui/tooltip text="Modify gateway settings"}}
|
|
18
|
-
{{> ui/btn variant="primary" style="outline" size="sm" href=(concat "/admin/gateways/edit/" gateway.gateway) icon="icon-[tabler--edit]" label="Edit gateway"}}
|
|
18
|
+
{{> ui/btn variant="primary" style="outline" size="sm" href=(concat "/admin/gateways/edit/" (urlpart gateway.gateway)) icon="icon-[tabler--edit]" label="Edit gateway"}}
|
|
19
19
|
{{/ui/tooltip}}
|
|
20
20
|
|
|
21
21
|
{{> ui/overflow-menu label="More gateway actions" deleteLabel="Delete gateway"}}
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
|
|
68
68
|
{{/ui/card}}
|
|
69
69
|
|
|
70
|
-
{{#> ui/confirm-modal id="deleteModal" title="Delete Gateway" action=(concat "/admin/gateways/delete/" gateway.gateway)
|
|
70
|
+
{{#> ui/confirm-modal id="deleteModal" title="Delete Gateway" action=(concat "/admin/gateways/delete/" (urlpart gateway.gateway))
|
|
71
71
|
submitLabel="Delete Gateway"}}
|
|
72
72
|
<p>Delete gateway "{{gateway.name}}"? This action cannot be undone.</p>
|
|
73
73
|
{{/ui/confirm-modal}}
|
package/views/gateways/index.hbs
CHANGED
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
{{#each gateways}}
|
|
25
25
|
<tr class="hover:bg-base-200/60">
|
|
26
26
|
<td class="relative">
|
|
27
|
-
{{> ui/row-link href=(concat "/admin/gateways/gateway/" gateway) label="Open gateway"}}
|
|
27
|
+
{{> ui/row-link href=(concat "/admin/gateways/gateway/" (urlpart gateway)) label="Open gateway"}}
|
|
28
28
|
<div><strong>{{name}}</strong></div>
|
|
29
29
|
{{> ui/entity-id id=gateway label="Gateway ID"}}
|
|
30
30
|
</td>
|
|
31
31
|
<td class="relative">
|
|
32
|
-
{{> ui/row-link href=(concat "/admin/gateways/gateway/" gateway)}}{{deliveries}}
|
|
32
|
+
{{> ui/row-link href=(concat "/admin/gateways/gateway/" (urlpart gateway))}}{{deliveries}}
|
|
33
33
|
</td>
|
|
34
34
|
|
|
35
35
|
<td class="relative">
|
|
36
|
-
{{> ui/row-link href=(concat "/admin/gateways/gateway/" gateway)}}
|
|
36
|
+
{{> ui/row-link href=(concat "/admin/gateways/gateway/" (urlpart gateway))}}
|
|
37
37
|
{{#if timeStr}}
|
|
38
38
|
<span class="relative-time" data-time="{{timeStr}}"></span>
|
|
39
39
|
{{else}}
|
|
@@ -42,17 +42,17 @@
|
|
|
42
42
|
</td>
|
|
43
43
|
|
|
44
44
|
<td class="relative w-32">
|
|
45
|
-
{{> ui/row-link href=(concat "/admin/gateways/gateway/" gateway)}}
|
|
45
|
+
{{> ui/row-link href=(concat "/admin/gateways/gateway/" (urlpart gateway))}}
|
|
46
46
|
{{!-- live state badge with an error tooltip; wrapping link
|
|
47
47
|
lifts the badge above the row overlay --}}
|
|
48
|
-
<a href="/admin/gateways/gateway/{{gateway}}" class="relative z-[1] inline-flex">
|
|
48
|
+
<a href="/admin/gateways/gateway/{{urlpart gateway}}" class="relative z-[1] inline-flex">
|
|
49
49
|
{{> ui/state-badge label=label account=gateway pointer=true}}
|
|
50
50
|
</a>
|
|
51
51
|
</td>
|
|
52
52
|
|
|
53
53
|
<td class="relative text-end">
|
|
54
|
-
{{> ui/row-actions openHref=(concat "/admin/gateways/gateway/" gateway) label="Gateway actions"
|
|
55
|
-
deleteModal="#deleteGateway" deleteName=name deleteAction=(concat "/admin/gateways/delete/" gateway)}}
|
|
54
|
+
{{> ui/row-actions openHref=(concat "/admin/gateways/gateway/" (urlpart gateway)) label="Gateway actions"
|
|
55
|
+
deleteModal="#deleteGateway" deleteName=name deleteAction=(concat "/admin/gateways/delete/" (urlpart gateway))}}
|
|
56
56
|
</td>
|
|
57
57
|
|
|
58
58
|
</tr>
|
|
@@ -29,16 +29,16 @@
|
|
|
29
29
|
{{#each accounts}}
|
|
30
30
|
<tr class="hover:bg-base-200/60">
|
|
31
31
|
<td class="relative">
|
|
32
|
-
{{> ui/row-link href=(concat "/admin/accounts/" account) label="Open account"}}
|
|
32
|
+
{{> ui/row-link href=(concat "/admin/accounts/" (urlpart account)) label="Open account"}}
|
|
33
33
|
<div><strong>{{name}}</strong></div>
|
|
34
34
|
{{> ui/entity-id id=account label="Account ID"}}
|
|
35
35
|
</td>
|
|
36
36
|
<td class="relative">
|
|
37
|
-
{{> ui/row-link href=(concat "/admin/accounts/" account)}}{{email}}
|
|
37
|
+
{{> ui/row-link href=(concat "/admin/accounts/" (urlpart account))}}{{email}}
|
|
38
38
|
</td>
|
|
39
39
|
|
|
40
40
|
<td class="relative">
|
|
41
|
-
{{> ui/row-link href=(concat "/admin/accounts/" account)}}
|
|
41
|
+
{{> ui/row-link href=(concat "/admin/accounts/" (urlpart account))}}
|
|
42
42
|
{{#if type.icon}}
|
|
43
43
|
{{!-- relative z-[1] lifts the tooltip trigger above the row link --}}
|
|
44
44
|
{{#> ui/tooltip text=type.label class="relative z-[1]"}}
|
|
@@ -53,13 +53,13 @@
|
|
|
53
53
|
</td>
|
|
54
54
|
|
|
55
55
|
<td class="relative w-32">
|
|
56
|
-
{{> ui/row-link href=(concat "/admin/accounts/" account)}}
|
|
56
|
+
{{> ui/row-link href=(concat "/admin/accounts/" (urlpart account))}}
|
|
57
57
|
{{!-- live state badge: app.js updates the badge-{type} class,
|
|
58
58
|
text and error tooltip through the /admin/changes SSE
|
|
59
59
|
feed. The wrapping link lifts the badge above the row
|
|
60
60
|
overlay so the tooltip fires while clicks still
|
|
61
61
|
navigate. --}}
|
|
62
|
-
<a href="/admin/accounts/{{account}}" class="relative z-[1] inline-flex">
|
|
62
|
+
<a href="/admin/accounts/{{urlpart account}}" class="relative z-[1] inline-flex">
|
|
63
63
|
{{> ui/state-badge label=stateLabel account=account pointer=true}}
|
|
64
64
|
</a>
|
|
65
65
|
</td>
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
row, not the partial params, so the cell silently vanished (phantom column) --}}
|
|
69
69
|
{{#if ../showActions}}
|
|
70
70
|
<td class="relative text-end">
|
|
71
|
-
{{> ui/row-actions openHref=(concat "/admin/accounts/" account) label="Account actions"
|
|
72
|
-
deleteModal="#deleteAccount" deleteName=(when name name email) deleteAction=(concat "/admin/accounts/" account "/delete")}}
|
|
71
|
+
{{> ui/row-actions openHref=(concat "/admin/accounts/" (urlpart account)) label="Account actions"
|
|
72
|
+
deleteModal="#deleteAccount" deleteName=(when name name email) deleteAction=(concat "/admin/accounts/" (urlpart account) "/delete")}}
|
|
73
73
|
</td>
|
|
74
74
|
{{/if}}
|
|
75
75
|
</tr>
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
<td>{{source}}</td>
|
|
32
32
|
<td>
|
|
33
33
|
{{#if account}}
|
|
34
|
-
<a href="/admin/accounts/{{account}}" class="link link-primary">{{account}}</a>
|
|
34
|
+
<a href="/admin/accounts/{{urlpart account}}" class="link link-primary">{{account}}</a>
|
|
35
35
|
{{else}}
|
|
36
36
|
<span class="text-base-content/60">-</span>
|
|
37
37
|
{{/if}}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
{{#if account}}
|
|
14
14
|
<div class="card-body">
|
|
15
15
|
<div>
|
|
16
|
-
Currently showing email templates for <strong><a href="/admin/accounts/{{account.account}}"
|
|
16
|
+
Currently showing email templates for <strong><a href="/admin/accounts/{{urlpart account.account}}"
|
|
17
17
|
class="link link-animated">{{account.name}}</a></strong>. These templates cannot be
|
|
18
18
|
used by other accounts.
|
|
19
19
|
</div>
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
{{#if account}}
|
|
65
65
|
{{#> ui/list-empty noun="templates" query=query firstPage=firstPage createHref=newLink createLabel="Create your first template" clearHref="/admin/templates"}}
|
|
66
66
|
<div class="mb-2">
|
|
67
|
-
Currently showing email templates for <strong><a href="/admin/accounts/{{account.account}}"
|
|
67
|
+
Currently showing email templates for <strong><a href="/admin/accounts/{{urlpart account.account}}"
|
|
68
68
|
class="link link-animated">{{#if account.name}}{{account.name}}{{else}}{{account.email}}{{/if}}</a></strong>.
|
|
69
69
|
These templates cannot be used by other accounts.
|
|
70
70
|
</div>
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
{{#if account}}
|
|
39
39
|
|
|
40
40
|
<dt>Account</dt>
|
|
41
|
-
<dd><a href="/admin/accounts/{{account.account}}" class="link link-animated">{{account.name}}</a></dd>
|
|
41
|
+
<dd><a href="/admin/accounts/{{urlpart account.account}}" class="link link-animated">{{account.name}}</a></dd>
|
|
42
42
|
|
|
43
43
|
{{/if}}
|
|
44
44
|
|
package/views/tokens/index.hbs
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
{{#if account}}
|
|
19
19
|
<div class="card-body">
|
|
20
20
|
<div>
|
|
21
|
-
Currently showing tokens for <strong><a href="/admin/accounts/{{account.account}}"
|
|
21
|
+
Currently showing tokens for <strong><a href="/admin/accounts/{{urlpart account.account}}"
|
|
22
22
|
class="link link-animated">{{account.name}}</a></strong>. These tokens cannot be
|
|
23
23
|
used by other accounts.
|
|
24
24
|
</div>
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
<thead>
|
|
30
30
|
<tr>
|
|
31
31
|
<th>Description</th>
|
|
32
|
+
{{#if showAccountColumn}}
|
|
33
|
+
<th>Bound to</th>
|
|
34
|
+
{{/if}}
|
|
32
35
|
<th>Scopes</th>
|
|
33
36
|
<th>Last used</th>
|
|
34
37
|
<th class="w-12"><span class="sr-only">Actions</span></th>
|
|
@@ -51,6 +54,23 @@
|
|
|
51
54
|
{{/if}}
|
|
52
55
|
</td>
|
|
53
56
|
|
|
57
|
+
{{#if ../showAccountColumn}}
|
|
58
|
+
<td class="align-top">
|
|
59
|
+
{{#if account}}
|
|
60
|
+
{{#if accountKnown}}
|
|
61
|
+
<a href="/admin/accounts/{{urlpart account}}" class="link link-animated">{{account}}</a>
|
|
62
|
+
{{else}}
|
|
63
|
+
<div>{{account}}</div>
|
|
64
|
+
{{!-- Deleting an account leaves its tokens behind and they still
|
|
65
|
+
authenticate, so this is a state to act on, not a rendering accident --}}
|
|
66
|
+
{{> ui/badge label="Account deleted" variant="warning" soft=true icon="" class="mt-1"}}
|
|
67
|
+
{{/if}}
|
|
68
|
+
{{else}}
|
|
69
|
+
<span class="text-base-content/60">All accounts</span>
|
|
70
|
+
{{/if}}
|
|
71
|
+
</td>
|
|
72
|
+
{{/if}}
|
|
73
|
+
|
|
54
74
|
<td class="align-top">
|
|
55
75
|
{{#if scopes}}
|
|
56
76
|
<div class="max-w-xs whitespace-normal">{{#each scopes}}{{#unless first}}, {{/unless}}{{name}}{{/each}}</div>
|
|
@@ -98,7 +118,7 @@
|
|
|
98
118
|
{{#if account}}
|
|
99
119
|
{{#> ui/list-empty noun="access tokens" query=query firstPage=firstPage createHref=newLink createLabel="Create your first access token" clearHref="/admin/tokens"}}
|
|
100
120
|
<div class="mb-2">
|
|
101
|
-
Currently showing tokens for <strong><a href="/admin/accounts/{{account.account}}"
|
|
121
|
+
Currently showing tokens for <strong><a href="/admin/accounts/{{urlpart account.account}}"
|
|
102
122
|
class="link link-animated">{{#if account.name}}{{account.name}}{{else}}{{account.email}}{{/if}}</a></strong>.
|
|
103
123
|
These tokens cannot be used by other accounts.
|
|
104
124
|
</div>
|
package/views/tokens/new.hbs
CHANGED
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
{{else}}
|
|
22
22
|
<form method="post" id="token-form" action="/admin/tokens/new">
|
|
23
23
|
<input type="hidden" name="crumb" value="{{crumb}}" />
|
|
24
|
-
<input type="hidden" id="account" name="account" value="{{values.account}}" />
|
|
25
24
|
|
|
26
25
|
<div class="card bg-base-100 shadow-md mb-6">
|
|
27
26
|
|
|
@@ -29,6 +28,11 @@
|
|
|
29
28
|
|
|
30
29
|
{{> ui/form-field id="description" label="Description" value=values.description error=errors.description required=true hint="This description is shown when listing active tokens."}}
|
|
31
30
|
|
|
31
|
+
{{!-- Free text rather than a select: an instance can hold far more accounts than a list
|
|
32
|
+
could usefully carry. The ID is resolved on submit, so a typo is refused rather than
|
|
33
|
+
minting a token bound to nothing. --}}
|
|
34
|
+
{{> ui/form-field id="account" label="Account ID (optional)" value=values.account error=errors.account placeholder="Leave empty to allow all accounts" hint="A bound token only works for that one account. Requests made for any other account are refused."}}
|
|
35
|
+
|
|
32
36
|
<div>
|
|
33
37
|
<h6 class="mb-2 font-bold">Allowed scopes</h6>
|
|
34
38
|
|
|
@@ -383,6 +387,10 @@
|
|
|
383
387
|
let description = document.getElementById('description').value.trim();
|
|
384
388
|
document.getElementById('description').value = description
|
|
385
389
|
|
|
390
|
+
// Trimmed so the redirect below filters the listing on the same value that was posted
|
|
391
|
+
let account = document.getElementById('account').value.trim();
|
|
392
|
+
document.getElementById('account').value = account
|
|
393
|
+
|
|
386
394
|
let collectAxis = selector =>
|
|
387
395
|
Array.from(document.querySelectorAll(selector))
|
|
388
396
|
.filter(elm => elm.checked)
|
|
@@ -409,7 +417,6 @@
|
|
|
409
417
|
showTokenValueElm.value = '';
|
|
410
418
|
|
|
411
419
|
if (wasShown) {
|
|
412
|
-
let account = document.getElementById('account').value || '';
|
|
413
420
|
location.assign("/admin/tokens" + (account ? '?account=' + encodeURIComponent(account) : ''));
|
|
414
421
|
}
|
|
415
422
|
}, { once: true });
|
|
@@ -447,7 +454,7 @@
|
|
|
447
454
|
description,
|
|
448
455
|
scopes,
|
|
449
456
|
permissions,
|
|
450
|
-
account
|
|
457
|
+
account
|
|
451
458
|
}).then(data => {
|
|
452
459
|
|
|
453
460
|
if (!data.success) {
|
package/workers/api.js
CHANGED
|
@@ -481,6 +481,11 @@ const init = async () => {
|
|
|
481
481
|
// keep using "danger" etc.
|
|
482
482
|
handlebars.registerHelper('eeColor', value => (value === 'danger' ? 'error' : value || 'neutral'));
|
|
483
483
|
|
|
484
|
+
// Percent-encode a value for interpolation into a URL path segment. Handlebars escapes for
|
|
485
|
+
// HTML, which leaves "#", "/", "?" and "%" untouched - and an account ID is free text, so
|
|
486
|
+
// href="/admin/accounts/{{account}}" resolves somewhere else entirely for an ID carrying one.
|
|
487
|
+
handlebars.registerHelper('urlpart', value => encodeURIComponent(value === null || value === undefined ? '' : value));
|
|
488
|
+
|
|
484
489
|
// Join string fragments in subexpressions, e.g. building composed partial
|
|
485
490
|
// hash values: text=(concat "Up to " (formatInteger n locale) " lines")
|
|
486
491
|
handlebars.registerHelper('concat', (...args) => args.slice(0, -1).join(''));
|
|
@@ -999,8 +1004,7 @@ const init = async () => {
|
|
|
999
1004
|
// The two listings that take the account as a query argument. `/v1/tokens` is
|
|
1000
1005
|
// here because it replaced GET /v1/tokens/account/{account}, which carried the
|
|
1001
1006
|
// account in the path and so reached a bound token's own tokens through the
|
|
1002
|
-
// default branch below -
|
|
1003
|
-
// the capability disappeared with no alias and no error a caller could act on.
|
|
1007
|
+
// default branch below - as its deprecated alias registration still does.
|
|
1004
1008
|
// Both stay under the same rule as everything else: the argument has to name the
|
|
1005
1009
|
// token's own account, and omitting it still refuses, because a bound credential
|
|
1006
1010
|
// must not enumerate the instance.
|
|
@@ -2739,13 +2743,37 @@ const init = async () => {
|
|
|
2739
2743
|
isCached: false,
|
|
2740
2744
|
|
|
2741
2745
|
async context(request) {
|
|
2742
|
-
|
|
2746
|
+
// The three reads are independent, and this runs on every admin page render. The
|
|
2747
|
+
// OAuth2 auth flags are best-effort - a failure to read them must not take the page
|
|
2748
|
+
// down with it.
|
|
2749
|
+
const [pendingMessages, settingsValues, oauthAuthFlags] = await Promise.all([
|
|
2750
|
+
flash(redis, request),
|
|
2751
|
+
settings.getMulti(
|
|
2752
|
+
'upgrade',
|
|
2753
|
+
'subexp',
|
|
2754
|
+
'webhookErrorFlag',
|
|
2755
|
+
'webhooksEnabled',
|
|
2756
|
+
'disableTokens',
|
|
2757
|
+
'tract',
|
|
2758
|
+
'templateHeader',
|
|
2759
|
+
'templateHtmlHead',
|
|
2760
|
+
'documentStoreEnabled',
|
|
2761
|
+
'serviceUrl',
|
|
2762
|
+
'language',
|
|
2763
|
+
'locale',
|
|
2764
|
+
'timezone',
|
|
2765
|
+
'pageBrandName',
|
|
2766
|
+
'notificationBaseUrl'
|
|
2767
|
+
),
|
|
2768
|
+
oauth2Apps.listAuthFlags().catch(err => {
|
|
2769
|
+
logger.error({ msg: 'Failed to list OAuth2 app auth flags', err });
|
|
2770
|
+
return [];
|
|
2771
|
+
})
|
|
2772
|
+
]);
|
|
2773
|
+
|
|
2743
2774
|
const {
|
|
2744
2775
|
upgrade: upgradeInfo,
|
|
2745
2776
|
subexp,
|
|
2746
|
-
outlookAuthFlag,
|
|
2747
|
-
gmailAuthFlag,
|
|
2748
|
-
gmailServiceAuthFlag,
|
|
2749
2777
|
webhookErrorFlag,
|
|
2750
2778
|
webhooksEnabled,
|
|
2751
2779
|
disableTokens,
|
|
@@ -2759,26 +2787,7 @@ const init = async () => {
|
|
|
2759
2787
|
timezone,
|
|
2760
2788
|
pageBrandName,
|
|
2761
2789
|
notificationBaseUrl
|
|
2762
|
-
} =
|
|
2763
|
-
'upgrade',
|
|
2764
|
-
'subexp',
|
|
2765
|
-
'outlookAuthFlag',
|
|
2766
|
-
'gmailAuthFlag',
|
|
2767
|
-
'gmailServiceAuthFlag',
|
|
2768
|
-
'webhookErrorFlag',
|
|
2769
|
-
'webhooksEnabled',
|
|
2770
|
-
'disableTokens',
|
|
2771
|
-
'tract',
|
|
2772
|
-
'templateHeader',
|
|
2773
|
-
'templateHtmlHead',
|
|
2774
|
-
'documentStoreEnabled',
|
|
2775
|
-
'serviceUrl',
|
|
2776
|
-
'language',
|
|
2777
|
-
'locale',
|
|
2778
|
-
'timezone',
|
|
2779
|
-
'pageBrandName',
|
|
2780
|
-
'notificationBaseUrl'
|
|
2781
|
-
);
|
|
2790
|
+
} = settingsValues;
|
|
2782
2791
|
|
|
2783
2792
|
let systemAlerts = [];
|
|
2784
2793
|
let authData;
|
|
@@ -2852,30 +2861,15 @@ const init = async () => {
|
|
|
2852
2861
|
});
|
|
2853
2862
|
}
|
|
2854
2863
|
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
icon: 'icon-[tabler--lock-open]',
|
|
2860
|
-
message: outlookAuthFlag.message
|
|
2861
|
-
});
|
|
2862
|
-
}
|
|
2863
|
-
|
|
2864
|
-
if (gmailAuthFlag && gmailAuthFlag.message) {
|
|
2865
|
-
systemAlerts.push({
|
|
2866
|
-
url: gmailAuthFlag.url || '/admin/config/oauth/app/gmail',
|
|
2867
|
-
level: 'danger',
|
|
2868
|
-
icon: 'icon-[tabler--lock-open]',
|
|
2869
|
-
message: gmailAuthFlag.message
|
|
2870
|
-
});
|
|
2871
|
-
}
|
|
2872
|
-
|
|
2873
|
-
if (gmailServiceAuthFlag && gmailServiceAuthFlag.message) {
|
|
2864
|
+
// OAuth2 apps whose token requests are being refused (setFlag() writes the failure
|
|
2865
|
+
// into app meta). Shown on every admin page: the accounts on such an app sit
|
|
2866
|
+
// disconnected until the operator acts, so the OAuth config page alone is not enough.
|
|
2867
|
+
for (let { app, authFlag } of oauthAuthFlags) {
|
|
2874
2868
|
systemAlerts.push({
|
|
2875
|
-
url:
|
|
2869
|
+
url: authFlag.url || `/admin/config/oauth/app/${encodeURIComponent(app)}`,
|
|
2876
2870
|
level: 'danger',
|
|
2877
2871
|
icon: 'icon-[tabler--lock-open]',
|
|
2878
|
-
message:
|
|
2872
|
+
message: authFlag.message
|
|
2879
2873
|
});
|
|
2880
2874
|
}
|
|
2881
2875
|
|