emailengine-app 2.80.0 → 2.80.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 +24 -0
- package/README.md +6 -0
- package/data/google-crawlers.json +1 -1
- package/lib/api-routes/account-routes.js +81 -1
- package/lib/api-routes/blocklist-routes.js +24 -0
- package/lib/api-routes/delivery-test-routes.js +6 -0
- package/lib/api-routes/gateway-routes.js +30 -0
- package/lib/api-routes/license-routes.js +10 -0
- package/lib/api-routes/mcp-oauth-routes.js +3 -3
- package/lib/api-routes/mcp-routes.js +39 -21
- package/lib/api-routes/oauth2-app-routes.js +38 -1
- package/lib/api-routes/outbox-routes.js +6 -0
- package/lib/api-routes/permission-map.js +208 -43
- package/lib/api-routes/pubsub-routes.js +8 -0
- package/lib/api-routes/route-helpers.js +58 -11
- package/lib/api-routes/settings-routes.js +50 -4
- package/lib/api-routes/stats-routes.js +6 -0
- package/lib/api-routes/template-routes.js +21 -0
- package/lib/api-routes/token-routes.js +34 -2
- package/lib/api-routes/webhook-route-routes.js +13 -0
- package/lib/email-client/base-client.js +6 -3
- package/lib/email-client/credential-errors.js +4 -0
- package/lib/email-client/imap/login-failure.js +52 -0
- package/lib/email-client/imap/subconnection.js +2 -1
- package/lib/email-client/imap-client.js +3 -6
- package/lib/enum-descriptions.js +12 -2
- package/lib/imapproxy/imap-server.js +1 -1
- package/lib/mcp/oauth.js +46 -8
- package/lib/mcp/protocol.js +78 -35
- package/lib/mcp/tools.js +53 -17
- package/lib/privileged-settings.js +147 -0
- package/lib/schemas.js +60 -16
- package/lib/settings.js +13 -0
- package/lib/tls/catalog.js +428 -0
- package/lib/tls/context.js +87 -161
- package/lib/tls/listeners.js +62 -0
- package/lib/tls/status.js +128 -79
- package/lib/tls/store.js +3 -2
- package/lib/token-permission-view.js +252 -102
- package/lib/token-permissions.js +176 -26
- package/lib/tokens.js +7 -6
- package/lib/tools.js +4 -3
- package/lib/ui-routes/admin-config-routes.js +41 -21
- package/lib/ui-routes/admin-entities-routes.js +23 -13
- package/lib/ui-routes/mcp-consent-routes.js +72 -31
- package/lib/ui-routes/tls-config-routes.js +121 -74
- package/package.json +12 -12
- package/sbom.json +1 -1
- package/server.js +7 -1
- package/static/css/flyonui.css +1 -1
- package/static/js/ui.js +89 -36
- package/static/licenses.html +46 -28
- package/translations/messages.pot +74 -68
- package/views/account/login-redirect.hbs +1 -1
- package/views/account/passkeys.hbs +2 -2
- package/views/accounts/account.hbs +2 -2
- package/views/accounts/browse.hbs +1 -1
- package/views/accounts/edit.hbs +1 -1
- package/views/accounts/register/imap-server.hbs +1 -1
- package/views/config/ai.hbs +1 -1
- package/views/config/branding.hbs +2 -2
- package/views/config/document-store/chat.hbs +1 -1
- package/views/config/document-store/index.hbs +1 -1
- package/views/config/imap-proxy.hbs +1 -1
- package/views/config/license.hbs +1 -1
- package/views/config/mcp.hbs +88 -52
- package/views/config/network.hbs +1 -1
- package/views/config/oauth/app.hbs +2 -2
- package/views/config/service.hbs +1 -1
- package/views/config/smtp.hbs +1 -1
- package/views/config/tls.hbs +266 -165
- package/views/config/webhooks.hbs +2 -2
- package/views/internals/index.hbs +1 -1
- package/views/layout/app.hbs +6 -6
- package/views/layout/login.hbs +5 -5
- package/views/layout/main.hbs +2 -2
- package/views/layout/prompt.hbs +3 -3
- package/views/layout/public.hbs +1 -1
- package/views/mcp/authorize.hbs +47 -45
- package/views/partials/ace_assets.hbs +1 -1
- package/views/partials/add_account_modal.hbs +1 -1
- package/views/partials/filter_editor_js.hbs +2 -2
- package/views/partials/gateway_js.hbs +1 -1
- package/views/partials/mcp_access_levels.hbs +16 -9
- package/views/partials/mcp_tool_count.hbs +15 -14
- package/views/partials/oauth_form.hbs +1 -1
- package/views/partials/public_theme_init.hbs +1 -1
- package/views/partials/template_form.hbs +1 -1
- package/views/partials/theme_init.hbs +1 -1
- package/views/partials/webhooks_editor_functions.hbs +1 -1
- package/views/reference/index.hbs +1 -1
- package/views/reference/redirect.hbs +1 -1
- package/views/reference/tag.hbs +1 -1
- package/views/reference/token.hbs +1 -1
- package/views/templates/template.hbs +1 -1
- package/views/tokens/new.hbs +175 -74
- package/views/unsubscribe.hbs +1 -1
- package/views/webhooks/webhook.hbs +1 -1
- package/workers/api.js +9 -8
- package/workers/smtp.js +1 -1
package/views/tokens/new.hbs
CHANGED
|
@@ -100,16 +100,33 @@
|
|
|
100
100
|
<p class="helper-text ms-7">Read the Prometheus metrics endpoint and nothing else.</p>
|
|
101
101
|
</li>
|
|
102
102
|
|
|
103
|
+
{{!-- Two MCP scopes, management first: the endpoint is one door with two tool
|
|
104
|
+
sets behind it, and each scope opens one of them. Both rows carry the Beta
|
|
105
|
+
badge the MCP config page carries. --}}
|
|
106
|
+
<li class="p-4">
|
|
107
|
+
<div class="flex items-center gap-2">
|
|
108
|
+
<input type="checkbox" class="checkbox checkbox-sm scope-entry scope-list" id="scopesMcpManage"
|
|
109
|
+
name="scopesMcpManage" data-scope="mcp-manage" {{#if values.scopesMcpManage}}checked{{/if}} />
|
|
110
|
+
<label class="label-text grow p-0" for="scopesMcpManage">MCP management
|
|
111
|
+
{{> ui/badge label="Beta" variant="info" soft=true class="badge-sm align-middle" icon="" elId=""}}</label>
|
|
112
|
+
<div class="text-base-content/60 code-link">["mcp-manage"]</div>
|
|
113
|
+
</div>
|
|
114
|
+
<p class="helper-text ms-7">Let an AI agent manage this instance through the MCP tools at
|
|
115
|
+
<code>/mcp</code>: accounts, settings, OAuth2 applications, gateways, tokens and the license.
|
|
116
|
+
This is not REST API access - the same token is refused by <code>/v1</code>.</p>
|
|
117
|
+
</li>
|
|
118
|
+
|
|
103
119
|
<li class="p-4">
|
|
104
120
|
<div class="flex items-center gap-2">
|
|
105
121
|
<input type="checkbox" class="checkbox checkbox-sm scope-entry scope-list" id="scopesMcp"
|
|
106
122
|
name="scopesMcp" data-scope="mcp" {{#if values.scopesMcp}}checked{{/if}} />
|
|
107
|
-
<label class="label-text grow p-0" for="scopesMcp">MCP
|
|
123
|
+
<label class="label-text grow p-0" for="scopesMcp">MCP mail
|
|
108
124
|
{{> ui/badge label="Beta" variant="info" soft=true class="badge-sm align-middle" icon="" elId=""}}</label>
|
|
109
125
|
<div class="text-base-content/60 code-link">["mcp"]</div>
|
|
110
126
|
</div>
|
|
111
|
-
<p class="helper-text ms-7">Let an AI agent
|
|
112
|
-
|
|
127
|
+
<p class="helper-text ms-7">Let an AI agent work with mailbox contents through the MCP tools at
|
|
128
|
+
<code>/mcp</code>: list, read, organize and send mail. This is not REST API access - the same
|
|
129
|
+
token is refused by <code>/v1</code>.</p>
|
|
113
130
|
{{!-- The endpoint is off by default, so an operator can otherwise mint a
|
|
114
131
|
credential for something that is not serving and only find out in the
|
|
115
132
|
client. Both halves of the gate are folded into mcpReady. Revealed by
|
|
@@ -138,7 +155,7 @@
|
|
|
138
155
|
The record itself stays single: one `permissions` object narrows whatever surface the
|
|
139
156
|
request arrives on. That is why this is one editor with two modes rather than a tab per
|
|
140
157
|
scope - separate panes would promise two records that cannot exist. --}}
|
|
141
|
-
<div id="accessCard" class="hidden" data-surfaces="{{permissionSurfacesJson}}" data-mcp-
|
|
158
|
+
<div id="accessCard" class="hidden" data-surfaces="{{permissionSurfacesJson}}" data-mcp-sections="{{json mcpSections}}">
|
|
142
159
|
{{#> ui/card bodyClass="space-y-4"}}
|
|
143
160
|
|
|
144
161
|
<div>
|
|
@@ -146,19 +163,29 @@
|
|
|
146
163
|
<p id="accessAppliesTo" class="text-base-content/60 text-sm"></p>
|
|
147
164
|
</div>
|
|
148
165
|
|
|
149
|
-
{{!-- MCP-only mode.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
166
|
+
{{!-- MCP-only mode. One level per MCP scope, shown while that scope is ticked above: the
|
|
167
|
+
same sections and levels the OAuth consent prompt and the MCP config page offer, from
|
|
168
|
+
the same table through the same partial, because the same credential minted from
|
|
169
|
+
three places must not mean three different things. A 72-cell matrix is not how
|
|
170
|
+
anyone provisions an agent, so it is the opt-in behind the levels rather than the way
|
|
171
|
+
in - and unlike the API editor there is no "restrict?" toggle: the narrowest level is
|
|
154
172
|
the default, because an agent credential that starts unrestricted is the wrong way
|
|
155
173
|
round. --}}
|
|
156
174
|
{{!-- Labelled by the card heading rather than carrying a legend of its own, which would
|
|
157
175
|
repeat "Access level" directly under itself --}}
|
|
158
|
-
<fieldset id="mcpLevelBlock" class="hidden space-y-
|
|
159
|
-
{{
|
|
160
|
-
|
|
161
|
-
|
|
176
|
+
<fieldset id="mcpLevelBlock" class="hidden space-y-4" aria-labelledby="accessCardTitle">
|
|
177
|
+
{{!-- One block per section, shown while that section's scope is ticked above; the radio
|
|
178
|
+
group is named mcpLevel_<key>, which is what the script and ui.js read back --}}
|
|
179
|
+
{{#each mcpSections}}
|
|
180
|
+
<div class="space-y-2 mcp-section-block" data-mcp-scope="{{scope}}">
|
|
181
|
+
<div class="label-text font-medium">{{label}}
|
|
182
|
+
<span class="text-base-content/60 code-link font-normal">["{{scope}}"]</span></div>
|
|
183
|
+
{{> mcp_access_levels section=this name=(concat "mcpLevel_" @key) idPrefix=(concat "mcpLevel_" @key) selected=levels.[0].value}}
|
|
184
|
+
</div>
|
|
185
|
+
{{/each}}
|
|
186
|
+
|
|
187
|
+
{{> ui/checkbox id="mcpCustom" label="Custom permissions" noName=true
|
|
188
|
+
hint="Choose the exact actions and sections yourself, starting from the levels selected above."}}
|
|
162
189
|
|
|
163
190
|
{{!-- At the decision point, as on the MCP config page: the level chosen here is what
|
|
164
191
|
decides whether instructions hidden inside received mail can act --}}
|
|
@@ -255,8 +282,9 @@
|
|
|
255
282
|
<span class="icon-[tabler--lock] size-5 shrink-0"></span>
|
|
256
283
|
<span>
|
|
257
284
|
Some endpoints are never available to a restricted token, whatever you select here:
|
|
258
|
-
|
|
259
|
-
|
|
285
|
+
creating access tokens, reading an account's live OAuth2 credential, and the settings
|
|
286
|
+
that would let a token widen itself ({{privilegedSettingsSummary}}). A token that
|
|
287
|
+
could reach those could grant itself more.
|
|
260
288
|
</span>
|
|
261
289
|
</div>
|
|
262
290
|
</div>
|
|
@@ -294,7 +322,7 @@
|
|
|
294
322
|
</div>
|
|
295
323
|
{{/ui/modal}}
|
|
296
324
|
|
|
297
|
-
<script nonce="{{cspNonce}}">
|
|
325
|
+
<script data-cfasync="false" nonce="{{cspNonce}}">
|
|
298
326
|
document.addEventListener('DOMContentLoaded', () => {
|
|
299
327
|
|
|
300
328
|
let showTokenValueElm = document.getElementById('showTokenValue');
|
|
@@ -334,13 +362,32 @@
|
|
|
334
362
|
};
|
|
335
363
|
}
|
|
336
364
|
|
|
337
|
-
|
|
338
|
-
//
|
|
339
|
-
|
|
340
|
-
let
|
|
365
|
+
// The two MCP access sections and what each level mints, from the same table the consent
|
|
366
|
+
// prompt and the MCP config page mint from
|
|
367
|
+
let mcpSections = JSON.parse(accessCardElm.dataset.mcpSections || '{}');
|
|
368
|
+
let mcpCustomElm = document.getElementById('mcpCustom');
|
|
369
|
+
|
|
370
|
+
let mcpScopes = Object.values(mcpSections).map(section => section.scope);
|
|
341
371
|
|
|
342
372
|
let scopeElms = Array.from(document.querySelectorAll('.scope-entry'));
|
|
343
373
|
let selectedScopes = () => scopeElms.filter(elm => elm.checked && !elm.disabled).map(elm => elm.dataset.scope);
|
|
374
|
+
let selectedMcpScopes = () => selectedScopes().filter(scope => mcpScopes.includes(scope));
|
|
375
|
+
|
|
376
|
+
// What the ticked MCP scopes can reach at all: the union of their surface tables. Read per
|
|
377
|
+
// call because it follows the scopes - a token holding only the management scope has no
|
|
378
|
+
// business ticking Messages in the custom editor.
|
|
379
|
+
let mcpCeilingFor = scopes => {
|
|
380
|
+
let ceiling = { actions: [], groups: [] };
|
|
381
|
+
for (let scope of scopes) {
|
|
382
|
+
let need = surfaceRequirements[scope];
|
|
383
|
+
if (!need) {
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
ceiling.actions = ceiling.actions.concat(need.actions.filter(value => !ceiling.actions.includes(value)));
|
|
387
|
+
ceiling.groups = ceiling.groups.concat(need.groups.filter(value => !ceiling.groups.includes(value)));
|
|
388
|
+
}
|
|
389
|
+
return ceiling;
|
|
390
|
+
};
|
|
344
391
|
|
|
345
392
|
// Permissions are resolved per endpoint on the REST API and per tool call on the MCP
|
|
346
393
|
// endpoint, so both of those scopes can carry a narrowing. The login-time scopes (SMTP,
|
|
@@ -353,7 +400,7 @@
|
|
|
353
400
|
// be greyed while this is open. That reads correctly: API access is granted by "All", and
|
|
354
401
|
// this is how to narrow it.
|
|
355
402
|
let hasApiScope = () => selectedScopes().some(scope => ['*', 'api'].includes(scope));
|
|
356
|
-
let hasMcpScope = () => selectedScopes().some(scope =>
|
|
403
|
+
let hasMcpScope = () => selectedScopes().some(scope => scope === '*' || mcpScopes.includes(scope));
|
|
357
404
|
let narrowableScope = () => hasApiScope() || hasMcpScope();
|
|
358
405
|
|
|
359
406
|
// The two editor modes. A token that reaches the MCP endpoint and not the REST API is a
|
|
@@ -363,9 +410,18 @@
|
|
|
363
410
|
// permissions record covers both surfaces and the API side needs all thirteen sections.
|
|
364
411
|
let mcpLevelMode = () => hasMcpScope() && !hasApiScope();
|
|
365
412
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
413
|
+
// The level per section, read through the shared helper: a section whose scope is not
|
|
414
|
+
// ticked has no radio group on screen and so comes back declined - the scope checkbox is
|
|
415
|
+
// this form's way of switching a section off
|
|
416
|
+
let selectedMcpLevels = () => {
|
|
417
|
+
let ticked = selectedMcpScopes();
|
|
418
|
+
let choice = uiMcpLevelChoice(mcpSections, 'mcpLevel_');
|
|
419
|
+
for (let key of Object.keys(mcpSections)) {
|
|
420
|
+
if (!ticked.includes(mcpSections[key].scope)) {
|
|
421
|
+
choice[key] = 'none';
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return choice;
|
|
369
425
|
};
|
|
370
426
|
|
|
371
427
|
// Sections the MCP surface can never reach are disabled while the level editor is showing,
|
|
@@ -396,29 +452,23 @@
|
|
|
396
452
|
// an empty one: it means the scopes are the only bound.
|
|
397
453
|
let effectiveRecord = () => {
|
|
398
454
|
if (mcpLevelMode()) {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
return { actions: record.actions, groups: record.groups, unrestricted: false };
|
|
404
|
-
}
|
|
405
|
-
// The full level is the one that legitimately stores no record. Any other level
|
|
406
|
-
// missing from the table means the table did not load, and a missing preset must
|
|
407
|
-
// not quietly mint a wider credential than the level on screen promises - the
|
|
408
|
-
// MCP config page's generator refuses the same way, and the consent route
|
|
409
|
-
// defaults the same direction.
|
|
410
|
-
return {
|
|
411
|
-
actions: mcpCeiling.actions,
|
|
412
|
-
groups: mcpCeiling.groups,
|
|
413
|
-
unrestricted: true,
|
|
414
|
-
unknownLevel: !Object.prototype.hasOwnProperty.call(mcpAccessPresets, level)
|
|
415
|
-
};
|
|
455
|
+
if (!mcpCustomElm.checked) {
|
|
456
|
+
// The pair list the selected levels mint, through the shared helper, so a level
|
|
457
|
+
// mints here exactly what it mints on the consent prompt
|
|
458
|
+
return uiMcpLevelRecord(mcpSections, selectedMcpLevels());
|
|
416
459
|
}
|
|
417
460
|
} else if (!permissionsEnabledElm.checked) {
|
|
418
461
|
return { actions: allActions, groups: Object.keys(axisLabels.group), unrestricted: true };
|
|
419
462
|
}
|
|
420
463
|
|
|
421
|
-
return {
|
|
464
|
+
return {
|
|
465
|
+
actions: tickedValues('.permission-action'),
|
|
466
|
+
groups: tickedValues('.permission-group'),
|
|
467
|
+
// The scope bound applies to a custom record too: the count must not promise a
|
|
468
|
+
// management tool to a token that only holds the mail scope
|
|
469
|
+
surfaces: mcpLevelMode() ? selectedMcpScopes() : undefined,
|
|
470
|
+
unrestricted: false
|
|
471
|
+
};
|
|
422
472
|
};
|
|
423
473
|
|
|
424
474
|
// Applies a permission record to the axes. Shared by the API presets and by the switch into
|
|
@@ -434,10 +484,11 @@
|
|
|
434
484
|
|
|
435
485
|
let syncAxisAvailability = () => {
|
|
436
486
|
let restrictToMcp = mcpLevelMode();
|
|
487
|
+
let ceiling = mcpCeilingFor(selectedMcpScopes());
|
|
437
488
|
|
|
438
489
|
for (let elm of document.querySelectorAll('.permission-axis')) {
|
|
439
490
|
let axis = elm.classList.contains('permission-action') ? 'actions' : 'groups';
|
|
440
|
-
let reachable = !restrictToMcp ||
|
|
491
|
+
let reachable = !restrictToMcp || ceiling[axis].includes(elm.dataset.value);
|
|
441
492
|
|
|
442
493
|
// Disabled rather than unticked: flipping the scopes back has to restore the
|
|
443
494
|
// selection rather than quietly lose it, and a disabled box is skipped by every
|
|
@@ -479,6 +530,35 @@
|
|
|
479
530
|
// stale count cannot survive a scope change.
|
|
480
531
|
window.uiMcpToolCount(mcpToolCountElm, hasMcpScope() ? Object.assign({ account: accountElm.value }, record) : null);
|
|
481
532
|
|
|
533
|
+
let rest = document.createElement('div');
|
|
534
|
+
rest.className = 'text-base-content/60';
|
|
535
|
+
rest.textContent = 'It cannot reach anything else, create tokens or read stored credentials.';
|
|
536
|
+
|
|
537
|
+
if (record.grants) {
|
|
538
|
+
// A level per section, each read out in the words of the table it came from
|
|
539
|
+
if (!record.grants.length) {
|
|
540
|
+
let line = document.createElement('div');
|
|
541
|
+
line.className = 'text-warning';
|
|
542
|
+
line.textContent = 'No access level is selected, so this token would not be able to do anything.';
|
|
543
|
+
permissionOutcomeTextElm.append(line);
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
let levels = selectedMcpLevels();
|
|
547
|
+
for (let key of Object.keys(mcpSections)) {
|
|
548
|
+
let level = mcpSections[key].levels.find(entry => entry.value === levels[key]);
|
|
549
|
+
if (!level) {
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
552
|
+
let line = document.createElement('div');
|
|
553
|
+
let label = document.createElement('strong');
|
|
554
|
+
label.textContent = mcpSections[key].label + ' (' + level.label + '): ';
|
|
555
|
+
line.append(label, document.createTextNode('can ' + level.actions + ' across ' + level.groups + '.'));
|
|
556
|
+
permissionOutcomeTextElm.append(line);
|
|
557
|
+
}
|
|
558
|
+
permissionOutcomeTextElm.append(rest);
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
|
|
482
562
|
if (!record.unrestricted && (!record.actions.length || !record.groups.length)) {
|
|
483
563
|
let line = document.createElement('div');
|
|
484
564
|
line.className = 'text-warning';
|
|
@@ -504,9 +584,6 @@
|
|
|
504
584
|
permissionOutcomeTextElm.append(cannot);
|
|
505
585
|
}
|
|
506
586
|
|
|
507
|
-
let rest = document.createElement('div');
|
|
508
|
-
rest.className = 'text-base-content/60';
|
|
509
|
-
rest.textContent = 'It cannot reach anything else, or read credentials and settings.';
|
|
510
587
|
permissionOutcomeTextElm.append(rest);
|
|
511
588
|
};
|
|
512
589
|
|
|
@@ -525,15 +602,18 @@
|
|
|
525
602
|
scopes = Object.keys(surfaceRequirements);
|
|
526
603
|
}
|
|
527
604
|
|
|
605
|
+
let covers = ([action, group]) => uiMcpRecordAllows(record, action, group);
|
|
606
|
+
|
|
528
607
|
let blocked = scopes
|
|
529
608
|
.filter(scope => surfaceRequirements[scope])
|
|
530
609
|
.filter(scope => {
|
|
531
610
|
let need = surfaceRequirements[scope];
|
|
532
611
|
if (need.mode === 'any') {
|
|
533
612
|
// Per-request surface: usable while any one (action, group) pair survives
|
|
534
|
-
return !need.grants.some(
|
|
613
|
+
return !need.grants.some(covers);
|
|
535
614
|
}
|
|
536
|
-
|
|
615
|
+
// Login-time surface: every pair it exercises has to survive
|
|
616
|
+
return !need.grants.every(covers);
|
|
537
617
|
})
|
|
538
618
|
.map(scope => surfaceRequirements[scope].label);
|
|
539
619
|
|
|
@@ -582,11 +662,18 @@
|
|
|
582
662
|
apiLimitBlockElm.classList.toggle('hidden', levelMode);
|
|
583
663
|
syncAxisAvailability();
|
|
584
664
|
|
|
585
|
-
//
|
|
665
|
+
// A section is shown while its scope is ticked: the scope checkbox is how this form
|
|
666
|
+
// declines a section, so an unticked scope must not leave a level on screen
|
|
667
|
+
let ticked = selectedMcpScopes();
|
|
668
|
+
for (let block of document.querySelectorAll('.mcp-section-block')) {
|
|
669
|
+
block.classList.toggle('hidden', !ticked.includes(block.dataset.mcpScope));
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
// The matrix is the detail view behind either mode: the "Custom permissions" opt-in on
|
|
586
673
|
// one side, the restriction toggle on the other. The API presets are shapes for the
|
|
587
674
|
// REST API, so they stay out of the way in level mode, where the named levels above
|
|
588
675
|
// are the presets.
|
|
589
|
-
permissionSectionElm.classList.toggle('hidden', levelMode ?
|
|
676
|
+
permissionSectionElm.classList.toggle('hidden', levelMode ? !mcpCustomElm.checked : !permissionsEnabledElm.checked);
|
|
590
677
|
permissionPresetRowElm.classList.toggle('hidden', levelMode);
|
|
591
678
|
};
|
|
592
679
|
|
|
@@ -594,7 +681,7 @@
|
|
|
594
681
|
// ticked - the default selection carries the mcp scope with everything else, and warning
|
|
595
682
|
// about a disabled endpoint on a page nobody opened for MCP is noise.
|
|
596
683
|
let mcpDisabledHintElm = document.getElementById('mcpDisabledHint');
|
|
597
|
-
let
|
|
684
|
+
let scopesMcpElms = [document.getElementById('scopesMcpManage'), document.getElementById('scopesMcp')];
|
|
598
685
|
|
|
599
686
|
let syncAll = () => {
|
|
600
687
|
syncAccessCard();
|
|
@@ -602,7 +689,7 @@
|
|
|
602
689
|
syncPermissionOutcome();
|
|
603
690
|
|
|
604
691
|
if (mcpDisabledHintElm) {
|
|
605
|
-
mcpDisabledHintElm.classList.toggle('hidden', !
|
|
692
|
+
mcpDisabledHintElm.classList.toggle('hidden', !scopesMcpElms.some(elm => elm.checked && !elm.disabled));
|
|
606
693
|
}
|
|
607
694
|
};
|
|
608
695
|
|
|
@@ -618,19 +705,28 @@
|
|
|
618
705
|
syncAll();
|
|
619
706
|
});
|
|
620
707
|
|
|
621
|
-
//
|
|
622
|
-
//
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
708
|
+
// Custom starts from the levels selected above, which is what its hint promises: the axes
|
|
709
|
+
// are seeded from the pairs those levels mint, which is the two-axis record closest to them
|
|
710
|
+
mcpCustomElm.addEventListener('change', () => {
|
|
711
|
+
if (mcpCustomElm.checked) {
|
|
712
|
+
let record = uiMcpLevelRecord(mcpSections, selectedMcpLevels());
|
|
713
|
+
let actions = [];
|
|
714
|
+
let groups = [];
|
|
715
|
+
for (let grant of record.grants) {
|
|
716
|
+
if (!actions.includes(grant.action)) {
|
|
717
|
+
actions.push(grant.action);
|
|
718
|
+
}
|
|
719
|
+
if (!groups.includes(grant.group)) {
|
|
720
|
+
groups.push(grant.group);
|
|
721
|
+
}
|
|
631
722
|
}
|
|
632
|
-
|
|
633
|
-
}
|
|
723
|
+
applyRecord(actions, groups);
|
|
724
|
+
}
|
|
725
|
+
syncAll();
|
|
726
|
+
});
|
|
727
|
+
|
|
728
|
+
for (let elm of document.querySelectorAll('input[name^="mcpLevel_"]')) {
|
|
729
|
+
elm.addEventListener('change', syncAll);
|
|
634
730
|
}
|
|
635
731
|
|
|
636
732
|
for (let elm of document.querySelectorAll('.permission-axis, .scope-entry')) {
|
|
@@ -689,12 +785,12 @@
|
|
|
689
785
|
document.getElementById('showTokenError').classList.add('hidden');
|
|
690
786
|
uiModal.open('#showToken');
|
|
691
787
|
|
|
692
|
-
// Omitting the field is what "not narrowed" means on the record, so an unchecked toggle
|
|
693
|
-
//
|
|
694
|
-
//
|
|
695
|
-
//
|
|
788
|
+
// Omitting the field is what "not narrowed" means on the record, so an unchecked toggle
|
|
789
|
+
// must not post an empty object. That is a different answer, and the API refuses it. An
|
|
790
|
+
// MCP token minted by level always carries its pair list explicitly, so what the operator
|
|
791
|
+
// saw is exactly what the credential holds.
|
|
696
792
|
let record = effectiveRecord();
|
|
697
|
-
let permissions = record.unrestricted ? null : { actions: record.actions, groups: record.groups };
|
|
793
|
+
let permissions = record.unrestricted ? null : record.grants ? { grants: record.grants } : { actions: record.actions, groups: record.groups };
|
|
698
794
|
|
|
699
795
|
let refuse = message => {
|
|
700
796
|
document.getElementById('showTokenLoader').classList.add('hidden');
|
|
@@ -704,10 +800,11 @@
|
|
|
704
800
|
uiModal.open('#showToken');
|
|
705
801
|
};
|
|
706
802
|
|
|
707
|
-
// The
|
|
708
|
-
// record
|
|
709
|
-
//
|
|
710
|
-
|
|
803
|
+
// The section table failed to load, so the levels on screen cannot be resolved to the
|
|
804
|
+
// record they promise. Refused rather than posted, as the MCP config page's generator
|
|
805
|
+
// refuses: what would go out is a record that grants nothing, which the API refuses
|
|
806
|
+
// too, but with an answer that names the wrong cause.
|
|
807
|
+
if (mcpLevelMode() && !mcpCustomElm.checked && !Object.keys(mcpSections).length) {
|
|
711
808
|
refuse('The access levels failed to load, so the selected level cannot be applied. Reload the page and try again.');
|
|
712
809
|
return;
|
|
713
810
|
}
|
|
@@ -715,7 +812,11 @@
|
|
|
715
812
|
// Said here rather than left to the schema. tokenPermissionsSchema refuses an empty axis
|
|
716
813
|
// too, but a joi rejection reaches this page as a bare "HTTP error! status: 400", which
|
|
717
814
|
// tells the reader nothing about the box they left unticked.
|
|
718
|
-
if (permissions &&
|
|
815
|
+
if (permissions && permissions.grants && !permissions.grants.length) {
|
|
816
|
+
refuse('Select an access level for at least one MCP scope. A token that grants nothing cannot make any request.');
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
if (permissions && permissions.actions && (!permissions.actions.length || !permissions.groups.length)) {
|
|
719
820
|
let missing = !permissions.actions.length ? 'action' : 'section';
|
|
720
821
|
refuse(`Select at least one ${missing}. A restriction that allows nothing would create a token that cannot make any request.`);
|
|
721
822
|
return;
|
package/views/unsubscribe.hbs
CHANGED
|
@@ -37,7 +37,7 @@ focus ring on) the corner close button --}}
|
|
|
37
37
|
</div>
|
|
38
38
|
</dialog>
|
|
39
39
|
|
|
40
|
-
<script nonce="{{cspNonce}}">
|
|
40
|
+
<script data-cfasync="false" nonce="{{cspNonce}}">
|
|
41
41
|
document.addEventListener('DOMContentLoaded', () => {
|
|
42
42
|
|
|
43
43
|
document.getElementById('resubscribe-link').addEventListener('click', e => {
|
|
@@ -153,7 +153,7 @@ fieldName="webhook" fieldValue=webhook.id submitLabel="Delete route"}}
|
|
|
153
153
|
|
|
154
154
|
{{> ace_assets}}
|
|
155
155
|
|
|
156
|
-
<script nonce="{{cspNonce}}">
|
|
156
|
+
<script data-cfasync="false" nonce="{{cspNonce}}">
|
|
157
157
|
document.addEventListener('DOMContentLoaded', () => {
|
|
158
158
|
|
|
159
159
|
{{!-- useWorker is false, so the JSHint options machinery the editable
|
package/workers/api.js
CHANGED
|
@@ -75,7 +75,7 @@ const tokenPermissions = require('../lib/token-permissions');
|
|
|
75
75
|
const { mcpFeatureEnabled } = require('../lib/mcp');
|
|
76
76
|
const mcpListen = require('../lib/mcp/listen');
|
|
77
77
|
const tokenAuditLog = require('../lib/token-audit-log');
|
|
78
|
-
const { routeGrant,
|
|
78
|
+
const { routeGrant, perRequestSurfaceAdmits, sessionTokenAdmits } = require('../lib/api-routes/permission-map');
|
|
79
79
|
const { mcpOptions } = require('../lib/api-routes/route-metadata');
|
|
80
80
|
|
|
81
81
|
const { redis, documentsQueue } = require('../lib/db');
|
|
@@ -542,6 +542,7 @@ const init = async () => {
|
|
|
542
542
|
apiTlsContext = await createTlsContext({
|
|
543
543
|
certs: certHandler,
|
|
544
544
|
logger,
|
|
545
|
+
listener: 'api',
|
|
545
546
|
// The operator's material and handshake settings are snapshotted inside, at entry,
|
|
546
547
|
// before the resolved options are merged back into this same object below
|
|
547
548
|
listenerOptions: API_TLS
|
|
@@ -931,13 +932,13 @@ const init = async () => {
|
|
|
931
932
|
account: (request.params && request.params.account) || queryAccount || tokenData.account || null
|
|
932
933
|
};
|
|
933
934
|
|
|
934
|
-
// `mcp`
|
|
935
|
-
//
|
|
936
|
-
// MCP endpoint dispatched itself -
|
|
937
|
-
// lib/mcp/inject.js and cannot be set from the
|
|
938
|
-
// presented to plain REST is refused here like any
|
|
939
|
-
|
|
940
|
-
|
|
935
|
+
// `mcp` and `mcp-manage` are surface scopes like `smtp`: each admits exactly the API
|
|
936
|
+
// operations its half of the MCP tool set wraps (perRequestSurfaceAdmits over
|
|
937
|
+
// SURFACE_GRANTS), and only on requests the MCP endpoint dispatched itself -
|
|
938
|
+
// request.app.mcpInternal is set by lib/mcp/inject.js and cannot be set from the
|
|
939
|
+
// network, so an mcp-scoped token presented to plain REST is refused here like any
|
|
940
|
+
// other missing scope.
|
|
941
|
+
const mcpSurfaceAdmits = scopes.includes('api') && !!request.app.mcpInternal && perRequestSurfaceAdmits(tokenData.scopes, grant);
|
|
941
942
|
|
|
942
943
|
const hasRequiredScope =
|
|
943
944
|
!scopes.length ||
|
package/workers/smtp.js
CHANGED
|
@@ -252,7 +252,7 @@ async function init() {
|
|
|
252
252
|
// The material loaded above is snapshotted inside, at entry. The resolved material is
|
|
253
253
|
// written back into serverOptions below, so a later refresh reading this object again would
|
|
254
254
|
// believe the operator had supplied whatever it resolved through the environment.
|
|
255
|
-
tlsContext = await createTlsContext({ certs, logger, listenerOptions: serverOptions });
|
|
255
|
+
tlsContext = await createTlsContext({ certs, logger, listener: 'smtp', listenerOptions: serverOptions });
|
|
256
256
|
Object.assign(serverOptions, tlsContext.options);
|
|
257
257
|
|
|
258
258
|
// Reached only when there is no material at all, which now means the self-signed fallback
|