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
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// The vocabulary a narrowed access token is written in, and the mapping from every registered /v1
|
|
4
|
+
// route onto it. Published per operation into /swagger.json as `x-ee-action` and `x-ee-group`, and
|
|
5
|
+
// read at request time by the api-token strategy, so a customer can see what each endpoint requires
|
|
6
|
+
// and the enforcement cannot disagree with the documentation.
|
|
7
|
+
//
|
|
8
|
+
// Two axes, both subtractive. `actions` says what a token may do, `groups` says what it may touch.
|
|
9
|
+
// Verbs are deliberately absent from the groups: `actions` already separates them, and a
|
|
10
|
+
// `message-delete` group would make two axes say the same thing.
|
|
11
|
+
|
|
12
|
+
const { resolveImpact, IMPACT } = require('./operation-impact');
|
|
13
|
+
const { pluginOptions } = require('./route-metadata');
|
|
14
|
+
|
|
15
|
+
// What a token may be allowed to do. Named apart from the impacts on purpose: `readonly` and
|
|
16
|
+
// `sends` describe a route, while `read` and `send` describe a grant on a credential, and the
|
|
17
|
+
// grant is written by whoever issues the token.
|
|
18
|
+
const ACTION = {
|
|
19
|
+
READ: 'read',
|
|
20
|
+
WRITE: 'write',
|
|
21
|
+
SEND: 'send',
|
|
22
|
+
DESTRUCTIVE: 'destructive'
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Splitting DESTRUCTIVE out from WRITE is the point of the axis rather than a detail of it: "an
|
|
26
|
+
// agent that can file and reply but not delete" is one bit, and it is the shape most often asked
|
|
27
|
+
// for.
|
|
28
|
+
//
|
|
29
|
+
// It separates the endpoints, not every route to the outcome, and the difference matters for
|
|
30
|
+
// messages specifically. EmailEngine deletes a message by moving it to Trash, so `write` on
|
|
31
|
+
// `message` - which has to allow filing mail into a folder the caller names - reaches the same end
|
|
32
|
+
// state as the DELETE the same token is refused, and `\Deleted` can be set through the flag update
|
|
33
|
+
// for the same reason. Withholding DESTRUCTIVE from a message grant is therefore a statement of
|
|
34
|
+
// intent about message content rather than a wall, and it is described that way wherever a token is
|
|
35
|
+
// issued. For everything genuinely irreversible - a folder, an export, a template, a gateway, a
|
|
36
|
+
// blocklist entry, a queued message - there is no write-shaped route to the same result, and the
|
|
37
|
+
// axis is a hard boundary. Closing the message case would mean reading a destination folder and a
|
|
38
|
+
// flag name out of a payload and deciding whether they amount to a deletion - a judgement about
|
|
39
|
+
// intent, unlike the one payload rule this model does make (see the note on GROUP.SUBMIT, which
|
|
40
|
+
// refuses a field outright rather than interpreting its value).
|
|
41
|
+
//
|
|
42
|
+
// Has to stay total over IMPACT - an impact with no action here resolves to undefined, which reads
|
|
43
|
+
// as an unclassifiable route and denies. test/api-routes-table-test.js asserts the totality.
|
|
44
|
+
const IMPACT_ACTIONS = {
|
|
45
|
+
[IMPACT.READONLY]: ACTION.READ,
|
|
46
|
+
[IMPACT.WRITE]: ACTION.WRITE,
|
|
47
|
+
[IMPACT.SENDS]: ACTION.SEND,
|
|
48
|
+
[IMPACT.DESTRUCTIVE]: ACTION.DESTRUCTIVE
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// What a token may be allowed to touch. Cut by what a grant exposes rather than by the tag the
|
|
52
|
+
// documentation files a route under: the display tags group `GET /v1/pubsub/status` with OAuth2
|
|
53
|
+
// client-secret writes, put the instance-wide `GET /v1/changes` stream under Account, and file the
|
|
54
|
+
// harmless `GET /v1/autoconfig` under Settings. Reusing them would mean a grant whose blast radius
|
|
55
|
+
// depends on a documentation decision.
|
|
56
|
+
const GROUP = {
|
|
57
|
+
// Account lifecycle and connection state. Credential reads are NOT here, see ADMIN.
|
|
58
|
+
ACCOUNT: 'account',
|
|
59
|
+
|
|
60
|
+
// Folder shape: create, rename, delete, list
|
|
61
|
+
MAILBOX: 'mailbox',
|
|
62
|
+
|
|
63
|
+
// Mail content, including the bulk actions. The largest group, and where `actions` does most
|
|
64
|
+
// of the work.
|
|
65
|
+
MESSAGE: 'message',
|
|
66
|
+
|
|
67
|
+
// Anything that hands a message to a mail server, including the delivery test. Note this reaches
|
|
68
|
+
// stored mail as well as sending it: a submit payload may carry `reference: {message, action:
|
|
69
|
+
// 'forward'}`, which reads the named message and delivers it. The check is route-level and does
|
|
70
|
+
// not inspect payloads, so `submit` is not a promise of no read access.
|
|
71
|
+
//
|
|
72
|
+
// One payload field is refused anyway, by assertNoNetworkOverride() in ./route-helpers.js:
|
|
73
|
+
// `proxy` decides where a session carrying the account's SMTP credentials connects, so a grant
|
|
74
|
+
// to send mail would otherwise be a route to reading the credential that sends it. That is a
|
|
75
|
+
// narrow exception rather than the start of a payload model - it is the only field here that
|
|
76
|
+
// DISCLOSES a stored credential. `gateway` selects one to send through, which a send grant
|
|
77
|
+
// reasonably covers and which reveals nothing (the same token cannot read GET /v1/gateways to
|
|
78
|
+
// learn the ids), and `baseUrl` only points tracking links at a host of the caller's choosing.
|
|
79
|
+
SUBMIT: 'submit',
|
|
80
|
+
|
|
81
|
+
// The sending queue: inspect and cancel
|
|
82
|
+
OUTBOX: 'outbox',
|
|
83
|
+
|
|
84
|
+
// Bulk export. Its own group because one call archives the whole account, so a token allowed
|
|
85
|
+
// to read messages should not get that for free.
|
|
86
|
+
EXPORT: 'export',
|
|
87
|
+
|
|
88
|
+
TEMPLATE: 'template',
|
|
89
|
+
BLOCKLIST: 'blocklist',
|
|
90
|
+
WEBHOOK: 'webhook',
|
|
91
|
+
|
|
92
|
+
// SMTP gateways, which hold outbound SMTP credentials
|
|
93
|
+
GATEWAY: 'gateway',
|
|
94
|
+
|
|
95
|
+
// The instance-wide change stream. Its own group because it is a firehose over every account
|
|
96
|
+
// rather than a request about one, so it should not ride along with an account grant.
|
|
97
|
+
EVENTS: 'events',
|
|
98
|
+
|
|
99
|
+
// Reads about the instance and its connections. Nothing here carries a credential or the
|
|
100
|
+
// contents of a message - the account log did, which is why it has its own group.
|
|
101
|
+
DIAGNOSTICS: 'diagnostics',
|
|
102
|
+
|
|
103
|
+
// The per-account log. Its own group because it discloses strictly more than any other read:
|
|
104
|
+
// the entries are the raw ImapFlow trace, so folder names, UIDs and untagged ENVELOPE responses
|
|
105
|
+
// carrying subjects and correspondents all land in it, and with EENGINE_LOG_RAW set the server
|
|
106
|
+
// frames go in whole. Granting it alongside `diagnostics` would have hidden mail content behind
|
|
107
|
+
// a word that promises none, and folding it into `message` would have made every reader of a
|
|
108
|
+
// mailbox a reader of the protocol trace as well.
|
|
109
|
+
LOGS: 'logs',
|
|
110
|
+
|
|
111
|
+
// Never grantable. See NEVER_GRANTABLE below.
|
|
112
|
+
ADMIN: 'admin'
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// Groups a `permissions` record may never name. The enforcement is in lib/token-permissions.js;
|
|
116
|
+
// what lives here is the policy it reads.
|
|
117
|
+
//
|
|
118
|
+
// A deny set rather than an absence from the grantable list, so widening the grantable list can
|
|
119
|
+
// never quietly reopen these.
|
|
120
|
+
const NEVER_GRANTABLE = new Set([GROUP.ADMIN]);
|
|
121
|
+
|
|
122
|
+
const GRANTABLE_GROUPS = Object.values(GROUP).filter(group => !NEVER_GRANTABLE.has(group));
|
|
123
|
+
|
|
124
|
+
// Every grant a non-HTTP surface can exercise once it has authenticated, rather than the one it
|
|
125
|
+
// nominally performs. These surfaces are checked once at login and never again, so a token is
|
|
126
|
+
// admitted only if it holds ALL of them.
|
|
127
|
+
//
|
|
128
|
+
// SMTP really is one operation: the server accepts a message and queues it. The IMAP proxy is not -
|
|
129
|
+
// after login lib/imapproxy/imap-server.js pipes the two sockets together, so the session can STORE
|
|
130
|
+
// \Deleted, EXPUNGE, APPEND, CREATE, DELETE and RENAME. Checking it as a single read would admit a
|
|
131
|
+
// token narrowed to reading and then hand it a session that can destroy the mailbox, which is a
|
|
132
|
+
// promise the surface cannot keep.
|
|
133
|
+
//
|
|
134
|
+
// Lives here rather than in lib/auth-token.js because it is policy that several places read - the
|
|
135
|
+
// admin form shows it to explain why a scope would be unusable - and auth-token.js reaches Redis,
|
|
136
|
+
// which a presentation module has no business loading.
|
|
137
|
+
const SURFACE_GRANTS = {
|
|
138
|
+
smtp: [{ action: ACTION.SEND, group: GROUP.SUBMIT }],
|
|
139
|
+
'imap-proxy': [
|
|
140
|
+
{ action: ACTION.READ, group: GROUP.MESSAGE },
|
|
141
|
+
{ action: ACTION.WRITE, group: GROUP.MESSAGE },
|
|
142
|
+
{ action: ACTION.DESTRUCTIVE, group: GROUP.MESSAGE },
|
|
143
|
+
{ action: ACTION.WRITE, group: GROUP.MAILBOX },
|
|
144
|
+
{ action: ACTION.DESTRUCTIVE, group: GROUP.MAILBOX }
|
|
145
|
+
],
|
|
146
|
+
// Not a submission surface: /metrics is an ordinary api-token route, so this mirrors its entry in
|
|
147
|
+
// GROUP_ROUTES below. Listed with the others because the admin form shows all three together.
|
|
148
|
+
metrics: [{ action: ACTION.READ, group: GROUP.DIAGNOSTICS }]
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// Membership sets for the two vocabularies. lib/token-permissions.js rejects a record naming
|
|
152
|
+
// anything outside them, which is what makes an unknown value a denial rather than something a
|
|
153
|
+
// reader silently drops.
|
|
154
|
+
//
|
|
155
|
+
// GROUP_VALUES deliberately includes ADMIN even though no record may name it: a record that does is
|
|
156
|
+
// well-formed but refused, which is a different answer from malformed, and the reason for the
|
|
157
|
+
// refusal should be "you may never have this" rather than "I could not read that".
|
|
158
|
+
const ACTION_VALUES = new Set(Object.values(ACTION));
|
|
159
|
+
const GROUP_VALUES = new Set(Object.values(GROUP));
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Identity of a route, in the `METHOD /path` form the rest of the test and helper code already uses
|
|
163
|
+
* for the same purpose, so the two listings of these 82 routes can be diffed against each other.
|
|
164
|
+
* Hapi reports a lowercase method on both `server.table()` entries and a live `request.route`.
|
|
165
|
+
*/
|
|
166
|
+
function routeKey(method, path) {
|
|
167
|
+
return `${String(method).toUpperCase()} ${path}`;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Every registered /v1 operation, by group. One entry per route rather than a rule per tag: a rule
|
|
171
|
+
// would give a newly added route the group of whatever tag it happened to carry, where an explicit
|
|
172
|
+
// entry means a new route has no group until someone chooses one, and no group is a denial.
|
|
173
|
+
//
|
|
174
|
+
// Grouped this way round because the access-control surface is then readable in one pass - the ADMIN
|
|
175
|
+
// block below IS the list of everything a narrowed token can never reach, rather than something a
|
|
176
|
+
// reviewer has to assemble by grepping. test/api-routes-table-test.js asserts this and the real
|
|
177
|
+
// route table agree exactly in both directions, so an added, removed or renamed route fails the
|
|
178
|
+
// build rather than drifting.
|
|
179
|
+
const GROUP_ROUTES = {
|
|
180
|
+
// Reading an account and operating on its connection. Creating one and editing its
|
|
181
|
+
// configuration are NOT here - see the note on those two entries under ADMIN.
|
|
182
|
+
[GROUP.ACCOUNT]: [
|
|
183
|
+
'GET /v1/accounts',
|
|
184
|
+
'GET /v1/account/{account}',
|
|
185
|
+
'DELETE /v1/account/{account}',
|
|
186
|
+
'PUT /v1/account/{account}/flush',
|
|
187
|
+
'PUT /v1/account/{account}/reconnect',
|
|
188
|
+
'PUT /v1/account/{account}/sync',
|
|
189
|
+
'GET /v1/account/{account}/server-signatures'
|
|
190
|
+
],
|
|
191
|
+
|
|
192
|
+
[GROUP.MAILBOX]: [
|
|
193
|
+
'GET /v1/account/{account}/mailboxes',
|
|
194
|
+
'POST /v1/account/{account}/mailbox',
|
|
195
|
+
'PUT /v1/account/{account}/mailbox',
|
|
196
|
+
'DELETE /v1/account/{account}/mailbox'
|
|
197
|
+
],
|
|
198
|
+
|
|
199
|
+
[GROUP.MESSAGE]: [
|
|
200
|
+
'GET /v1/account/{account}/messages',
|
|
201
|
+
'POST /v1/account/{account}/search',
|
|
202
|
+
'GET /v1/account/{account}/message/{message}',
|
|
203
|
+
'PUT /v1/account/{account}/message/{message}',
|
|
204
|
+
'DELETE /v1/account/{account}/message/{message}',
|
|
205
|
+
'PUT /v1/account/{account}/message/{message}/move',
|
|
206
|
+
'GET /v1/account/{account}/message/{message}/source',
|
|
207
|
+
'POST /v1/account/{account}/message',
|
|
208
|
+
'GET /v1/account/{account}/text/{text}',
|
|
209
|
+
'GET /v1/account/{account}/attachment/{attachment}',
|
|
210
|
+
'PUT /v1/account/{account}/messages',
|
|
211
|
+
'PUT /v1/account/{account}/messages/move',
|
|
212
|
+
'PUT /v1/account/{account}/messages/delete'
|
|
213
|
+
],
|
|
214
|
+
|
|
215
|
+
[GROUP.SUBMIT]: [
|
|
216
|
+
'POST /v1/account/{account}/submit',
|
|
217
|
+
'POST /v1/account/{account}/message/{message}/submit',
|
|
218
|
+
// Sends a real message to a probe address, so it belongs with sending rather than with the
|
|
219
|
+
// diagnostics read that later collects the result
|
|
220
|
+
'POST /v1/delivery-test/account/{account}'
|
|
221
|
+
],
|
|
222
|
+
|
|
223
|
+
[GROUP.OUTBOX]: ['GET /v1/outbox', 'GET /v1/outbox/{queueId}', 'DELETE /v1/outbox/{queueId}'],
|
|
224
|
+
|
|
225
|
+
[GROUP.EXPORT]: [
|
|
226
|
+
'POST /v1/account/{account}/export',
|
|
227
|
+
'GET /v1/account/{account}/exports',
|
|
228
|
+
'GET /v1/account/{account}/export/{exportId}',
|
|
229
|
+
'GET /v1/account/{account}/export/{exportId}/download',
|
|
230
|
+
'DELETE /v1/account/{account}/export/{exportId}'
|
|
231
|
+
],
|
|
232
|
+
|
|
233
|
+
[GROUP.TEMPLATE]: [
|
|
234
|
+
'GET /v1/templates',
|
|
235
|
+
'POST /v1/templates/template',
|
|
236
|
+
'GET /v1/templates/template/{template}',
|
|
237
|
+
'PUT /v1/templates/template/{template}',
|
|
238
|
+
'DELETE /v1/templates/template/{template}',
|
|
239
|
+
'DELETE /v1/templates/account/{account}'
|
|
240
|
+
],
|
|
241
|
+
|
|
242
|
+
[GROUP.BLOCKLIST]: ['GET /v1/blocklists', 'GET /v1/blocklist/{listId}', 'POST /v1/blocklist/{listId}', 'DELETE /v1/blocklist/{listId}'],
|
|
243
|
+
|
|
244
|
+
[GROUP.WEBHOOK]: ['GET /v1/webhookRoutes', 'GET /v1/webhookRoutes/webhookRoute/{webhookRoute}'],
|
|
245
|
+
|
|
246
|
+
// Reading a gateway and removing one. The two WRITES are in ADMIN below, because they can
|
|
247
|
+
// redirect where the stored relay credentials are sent - so they are deliberately absent here
|
|
248
|
+
// rather than listed in both places.
|
|
249
|
+
[GROUP.GATEWAY]: ['GET /v1/gateways', 'GET /v1/gateway/{gateway}', 'DELETE /v1/gateway/{gateway}'],
|
|
250
|
+
|
|
251
|
+
[GROUP.EVENTS]: ['GET /v1/changes'],
|
|
252
|
+
|
|
253
|
+
[GROUP.DIAGNOSTICS]: [
|
|
254
|
+
'GET /v1/stats',
|
|
255
|
+
'GET /v1/delivery-test/check/{deliveryTest}',
|
|
256
|
+
'GET /v1/pubsub/status',
|
|
257
|
+
'GET /v1/autoconfig',
|
|
258
|
+
// The Prometheus endpoint. Not a /v1 route and registered in workers/api.js rather than
|
|
259
|
+
// lib/api-routes/index.js, so the route table test cannot see it - listed here anyway
|
|
260
|
+
// because it authenticates with the same tokens. Without an entry it resolves to no group,
|
|
261
|
+
// and a narrowed token is refused on it: a `metrics`-scoped token that set any permissions
|
|
262
|
+
// at all became unusable, including one asking for exactly this.
|
|
263
|
+
'GET /metrics'
|
|
264
|
+
],
|
|
265
|
+
|
|
266
|
+
[GROUP.LOGS]: ['GET /v1/logs/{account}'],
|
|
267
|
+
|
|
268
|
+
// Everything that hands out a lasting credential or widens what the instance can do. This block
|
|
269
|
+
// is the safety property of the whole model: while a narrowed token cannot reach any of it, it
|
|
270
|
+
// cannot read the settings blob, cannot read a stored OAuth2 credential, and cannot mint or
|
|
271
|
+
// revoke a token, so it cannot widen itself.
|
|
272
|
+
[GROUP.ADMIN]: [
|
|
273
|
+
'GET /v1/settings',
|
|
274
|
+
'POST /v1/settings',
|
|
275
|
+
'GET /v1/settings/queue/{queue}',
|
|
276
|
+
'PUT /v1/settings/queue/{queue}',
|
|
277
|
+
|
|
278
|
+
'GET /v1/oauth2',
|
|
279
|
+
'POST /v1/oauth2',
|
|
280
|
+
'GET /v1/oauth2/{app}',
|
|
281
|
+
'PUT /v1/oauth2/{app}',
|
|
282
|
+
'DELETE /v1/oauth2/{app}',
|
|
283
|
+
'POST /v1/oauth2/{app}/verify',
|
|
284
|
+
|
|
285
|
+
'GET /v1/license',
|
|
286
|
+
'POST /v1/license',
|
|
287
|
+
'DELETE /v1/license',
|
|
288
|
+
|
|
289
|
+
'POST /v1/tokens',
|
|
290
|
+
'DELETE /v1/tokens/{token}',
|
|
291
|
+
'GET /v1/tokens',
|
|
292
|
+
// Who read whose mail with this credential. Admin because the trail is at least as sensitive
|
|
293
|
+
// as the requests in it, and a narrowed token has no business reading its own audit record.
|
|
294
|
+
'GET /v1/tokens/{token}',
|
|
295
|
+
'GET /v1/tokens/{token}/log',
|
|
296
|
+
|
|
297
|
+
// Returns a live OAuth2 access token for the account: a mail credential in its own right,
|
|
298
|
+
// which outlives any narrowing on the token that fetched it
|
|
299
|
+
'GET /v1/account/{account}/oauth-token',
|
|
300
|
+
|
|
301
|
+
// Editing an account is a credential operation even when the payload carries no credential,
|
|
302
|
+
// which is why it sits here and not in the grantable `account` group. `imap`, `smtp` and
|
|
303
|
+
// `oauth2` accept `partial: true`, and Account.persistUpdate() then merges the STORED object
|
|
304
|
+
// over the payload (lib/account.js:858), so `auth.pass` survives a request that only changes
|
|
305
|
+
// `host`. An 'imap' key also arms the reconnect gate, so the worker promptly authenticates
|
|
306
|
+
// to the new host with the old password. The same route retargets `proxy` and the
|
|
307
|
+
// per-account `webhooks` URL, which would stream future message notifications - body text
|
|
308
|
+
// included, up to notifyTextSize - somewhere else entirely.
|
|
309
|
+
'PUT /v1/account/{account}',
|
|
310
|
+
|
|
311
|
+
// Adds an account, so it widens what the instance holds. Grouped with the hosted form below
|
|
312
|
+
// for the same reason, and it can set the same webhook and proxy targets as the edit above.
|
|
313
|
+
'POST /v1/account',
|
|
314
|
+
|
|
315
|
+
// The same shape as the account edit above, and for the same reason. Gateway.update() writes
|
|
316
|
+
// only the keys the payload carries (lib/gateway.js:233), so a request setting just `host`
|
|
317
|
+
// leaves the encrypted `user` and `pass` in place - and the next message routed through that
|
|
318
|
+
// gateway performs SMTP AUTH against the new host with the customer's relay credentials.
|
|
319
|
+
// Reading them back is masked; sending them somewhere is not.
|
|
320
|
+
'POST /v1/gateway',
|
|
321
|
+
'PUT /v1/gateway/edit/{gateway}',
|
|
322
|
+
|
|
323
|
+
// Mints a hosted account-add URL, so it grows the set of accounts the instance holds
|
|
324
|
+
'POST /v1/authentication/form',
|
|
325
|
+
|
|
326
|
+
// Connects to a supplied host with supplied credentials
|
|
327
|
+
'POST /v1/verifyAccount',
|
|
328
|
+
|
|
329
|
+
// The deprecated Document Store. Disabled by default and leaving the releases on
|
|
330
|
+
// 2026-10-01, so keeping it out of the grantable vocabulary means the removal does not
|
|
331
|
+
// retire a slug a customer had written into a token.
|
|
332
|
+
'POST /v1/chat/{account}',
|
|
333
|
+
'POST /v1/unified/search'
|
|
334
|
+
]
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
// Inverted once at load, refusing a route that appears under two groups.
|
|
338
|
+
//
|
|
339
|
+
// The refusal is the point. Building this with `new Map(...)` let the later entry win silently, and
|
|
340
|
+
// it had already happened: the two gateway writes were listed under both `gateway` and `admin`, and
|
|
341
|
+
// only the order of the literal decided that the never-grantable one took effect. The route-table
|
|
342
|
+
// test cannot see it either - it compares this map's size against the route table, and a duplicate
|
|
343
|
+
// leaves the size unchanged. Throwing at load turns "whichever is written last" into a build
|
|
344
|
+
// failure, in a table where one of the two answers is a grant a customer must never be able to hold.
|
|
345
|
+
const ROUTE_GROUPS = new Map();
|
|
346
|
+
for (const [group, routes] of Object.entries(GROUP_ROUTES)) {
|
|
347
|
+
for (const route of routes) {
|
|
348
|
+
if (ROUTE_GROUPS.has(route)) {
|
|
349
|
+
throw new Error(`${route} is listed under two permission groups, ${ROUTE_GROUPS.get(route)} and ${group}`);
|
|
350
|
+
}
|
|
351
|
+
ROUTE_GROUPS.set(route, group);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Resolves the action an operation requires.
|
|
357
|
+
*
|
|
358
|
+
* @param {String} [declared] - the route's `x-ee-impact`, if it sets one
|
|
359
|
+
* @param {String} method - HTTP method
|
|
360
|
+
* @returns {String|null} one of ACTION, or null when the impact does not resolve
|
|
361
|
+
*/
|
|
362
|
+
function resolveAction(declared, method) {
|
|
363
|
+
const impact = resolveImpact(declared, method);
|
|
364
|
+
return impact ? IMPACT_ACTIONS[impact] || null : null;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* The grant a route requires, for a Hapi route from `server.table()` or a live `request.route`.
|
|
369
|
+
*
|
|
370
|
+
* Either half can be null, and null always means deny: an operation whose action or group does not
|
|
371
|
+
* resolve is one this vocabulary does not describe, and guessing is how a route ends up ungoverned.
|
|
372
|
+
* The route table test asserts neither half is ever null for a registered /v1 route, so a null here
|
|
373
|
+
* means the table and the routes have diverged.
|
|
374
|
+
*
|
|
375
|
+
* @param {Object} route - `server.table()` entry or `request.route`
|
|
376
|
+
* @returns {{action: (String|null), group: (String|null)}}
|
|
377
|
+
*/
|
|
378
|
+
function routeGrant(route) {
|
|
379
|
+
return {
|
|
380
|
+
action: resolveAction(pluginOptions(route)['x-ee-impact'], route && route.method),
|
|
381
|
+
group: ROUTE_GROUPS.get(routeKey(route && route.method, route && route.path)) || null
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
module.exports = {
|
|
386
|
+
ACTION,
|
|
387
|
+
GROUP,
|
|
388
|
+
SURFACE_GRANTS,
|
|
389
|
+
GRANTABLE_GROUPS,
|
|
390
|
+
ACTION_VALUES,
|
|
391
|
+
GROUP_VALUES,
|
|
392
|
+
NEVER_GRANTABLE,
|
|
393
|
+
IMPACT_ACTIONS,
|
|
394
|
+
ROUTE_GROUPS,
|
|
395
|
+
routeKey,
|
|
396
|
+
routeGrant
|
|
397
|
+
};
|
|
@@ -1,26 +1,35 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const Boom = require('@hapi/boom');
|
|
4
|
+
const tokenPermissions = require('../token-permissions');
|
|
4
5
|
|
|
5
6
|
// Shared helpers for the extracted API route modules under lib/api-routes/.
|
|
6
7
|
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
function
|
|
8
|
+
// Derives the failure's HTTP status and logs it under the shared level policy. Kept separate from
|
|
9
|
+
// handleError for the few catch blocks that need a custom response shape but must not fork the
|
|
10
|
+
// logging policy. Unlike handleError this only logs: it RETURNS the derived statusCode instead of
|
|
11
|
+
// throwing, so a caller that uses it must still produce a response of its own.
|
|
12
|
+
function logApiError(request, err) {
|
|
12
13
|
// Lower-level libraries (e.g. ImapFlow) flag "this server lacks the required capability" with a
|
|
13
14
|
// machine code but no HTTP status. Surface it as a 422 client error instead of a generic 500 - the
|
|
14
15
|
// request is well-formed, the account just cannot satisfy it (e.g. label search on non-Gmail IMAP).
|
|
15
|
-
let
|
|
16
|
-
let statusCode = isBoom ? err.output.statusCode : err.statusCode || (err.code === 'MissingServerExtension' ? 422 : 500);
|
|
16
|
+
let statusCode = Boom.isBoom(err) ? err.output.statusCode : err.statusCode || (err.code === 'MissingServerExtension' ? 422 : 500);
|
|
17
17
|
|
|
18
18
|
// Log expected client errors (4xx, e.g. a 404 from an existence-check probe) at warn so they do not
|
|
19
19
|
// flood the error stream, while genuine server faults (5xx) stay at error.
|
|
20
20
|
let logLevel = statusCode >= 400 && statusCode < 500 ? 'warn' : 'error';
|
|
21
21
|
request.logger[logLevel]({ msg: 'API request failed', statusCode, err });
|
|
22
|
+
return statusCode;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Standard API error handler. Logs the failure, passes Boom errors through unchanged, and converts
|
|
26
|
+
// plain errors into a Boom error while preserving the original statusCode and an optional
|
|
27
|
+
// machine-readable err.code. This function ALWAYS throws and never returns a value, so callers use it
|
|
28
|
+
// as the final statement inside a catch block: `catch (err) { handleError(request, err); }`.
|
|
29
|
+
function handleError(request, err) {
|
|
30
|
+
let statusCode = logApiError(request, err);
|
|
22
31
|
|
|
23
|
-
if (isBoom) {
|
|
32
|
+
if (Boom.isBoom(err)) {
|
|
24
33
|
throw err;
|
|
25
34
|
}
|
|
26
35
|
const error = Boom.boomify(err, { statusCode });
|
|
@@ -64,4 +73,209 @@ function flattenOAuthAppMeta(app) {
|
|
|
64
73
|
}
|
|
65
74
|
}
|
|
66
75
|
|
|
67
|
-
|
|
76
|
+
// What a masked secret reads as in an API response. Same marker the account, gateway and OAuth2-app
|
|
77
|
+
// getters already use for stored passwords, so a client sees one convention.
|
|
78
|
+
const MASKED = '******';
|
|
79
|
+
|
|
80
|
+
// One sentence for every endpoint that returns a masked entity, so the document says what a reader
|
|
81
|
+
// will actually get back. The convention predates this - the gateway getter already documented its
|
|
82
|
+
// masked password - but the wording lived in each route.
|
|
83
|
+
const MASK_NOTE =
|
|
84
|
+
'Credentials are masked: stored passwords, the credentials in any proxy or webhook URL, and the values of custom webhook headers all read back as "%s". A masked value is not the stored one - leave the field out of an update rather than writing it back, otherwise the mask replaces the credential.'.replace(
|
|
85
|
+
'%s',
|
|
86
|
+
MASKED
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
// Masks the VALUES of a custom-header list, keeping the keys.
|
|
90
|
+
//
|
|
91
|
+
// These carry credentials for someone else's system - the documented example is
|
|
92
|
+
// `Authorization: Bearer <token>` - and they were returned in full by the account and webhook-route
|
|
93
|
+
// getters while the passwords next to them were masked. Reading one back is enough to post forged,
|
|
94
|
+
// correctly authenticated webhooks into the customer's receiver.
|
|
95
|
+
//
|
|
96
|
+
// The keys stay visible because they carry no secret and are what makes the response useful: a
|
|
97
|
+
// reader can see THAT an Authorization header is configured without being handed its value.
|
|
98
|
+
function maskCustomHeaders(headers) {
|
|
99
|
+
if (!Array.isArray(headers)) {
|
|
100
|
+
return headers;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// A header with no value has no secret to hide, and masking it would advertise one that is not
|
|
104
|
+
// there - the schema defaults `value` to an empty string, so this is a real stored shape.
|
|
105
|
+
return headers.map(header => (header && typeof header === 'object' && header.value ? Object.assign({}, header, { value: MASKED }) : header));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Masks the credentials in a URL, keeping everything that identifies where it points.
|
|
109
|
+
//
|
|
110
|
+
// Several stored URLs accept inline credentials - `proxyUrl` as `socks5://user:pass@host:1080`, and
|
|
111
|
+
// webhook targets as `https://user:pass@receiver.example.com/hook` - so returning them verbatim
|
|
112
|
+
// published a working credential. Host, port and path stay: they are operational information a
|
|
113
|
+
// client legitimately reads back, and blanking them would break anything that displays the value.
|
|
114
|
+
//
|
|
115
|
+
// Distinct from redactUrlCredentials() in lib/tools.js, which serves the log stream: that one may
|
|
116
|
+
// return a placeholder that is not a URL at all. This one has to come back schema-valid and still
|
|
117
|
+
// identify the destination, because it lands in an API response - which is also why it replaces the
|
|
118
|
+
// credentials in place rather than dropping the userinfo section.
|
|
119
|
+
function maskUrlPassword(url) {
|
|
120
|
+
if (!url || typeof url !== 'string') {
|
|
121
|
+
return url;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let parsed;
|
|
125
|
+
try {
|
|
126
|
+
parsed = new URL(url);
|
|
127
|
+
} catch (err) {
|
|
128
|
+
// An unparseable value could itself be the credential that made it unparseable, so it is
|
|
129
|
+
// replaced rather than echoed - the same call lib/tools.js makes for the log stream. Empty
|
|
130
|
+
// rather than a placeholder because every schema here allows it, and a value that cannot be
|
|
131
|
+
// parsed was never a usable destination anyway.
|
|
132
|
+
return '';
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Gated on either half: commercial proxies commonly key on a token in the USERNAME with no
|
|
136
|
+
// password at all, and lib/tools.js reads that shape (userId with an empty password).
|
|
137
|
+
if (!parsed.username && !parsed.password) {
|
|
138
|
+
return url;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Each half is masked only where there is one. Rewriting only the password published the
|
|
142
|
+
// username in full, which for the shape above IS the credential - and writing a password into a
|
|
143
|
+
// URL that never had one reports a secret that does not exist, showing the account as more
|
|
144
|
+
// configured than it is.
|
|
145
|
+
if (parsed.username) {
|
|
146
|
+
parsed.username = MASKED;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (parsed.password) {
|
|
150
|
+
parsed.password = MASKED;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return parsed.href;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Stored values that are URLs which may embed a password.
|
|
157
|
+
const URL_SECRET_KEYS = ['proxy', 'proxyUrl', 'httpProxyUrl', 'webhooks', 'targetUrl'];
|
|
158
|
+
|
|
159
|
+
// Stored values that are {key, value} header lists whose values are credentials.
|
|
160
|
+
const HEADER_SECRET_KEYS = ['customHeaders', 'webhooksCustomHeaders'];
|
|
161
|
+
|
|
162
|
+
// A failed submission records the route it took, including the proxy it used, and that record is
|
|
163
|
+
// then persisted onto the account, the gateway and the queue entry. So the same proxy URL reappears
|
|
164
|
+
// nested inside a status or error object, one field over from where it was masked.
|
|
165
|
+
function maskNetworkRouting(container) {
|
|
166
|
+
if (!container || typeof container !== 'object') {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (container.networkRouting && typeof container.networkRouting === 'object' && container.networkRouting.proxy) {
|
|
171
|
+
container.networkRouting.proxy = maskUrlPassword(container.networkRouting.proxy);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Masks every credential-bearing field of an entity about to be returned from the API.
|
|
177
|
+
*
|
|
178
|
+
* One function rather than a mask call per field per handler, because the leak this closes was
|
|
179
|
+
* exactly the failure mode of doing it per field: `proxy` was masked in the account getter while the
|
|
180
|
+
* same URL came back through `smtpStatus.networkRouting.proxy` in the same response body, and
|
|
181
|
+
* `customHeaders` was masked in the webhook getter while `targetUrl` beside it carried basic auth.
|
|
182
|
+
* With the field set in one place, a newly added handler gets all of them and a newly added secret
|
|
183
|
+
* field reaches every handler at once.
|
|
184
|
+
*
|
|
185
|
+
* Containers are enumerated rather than walked recursively on purpose: an outbox entry carries the
|
|
186
|
+
* submitted message, and a recursive scan would read through mail content to find nothing.
|
|
187
|
+
*
|
|
188
|
+
* Mutates and returns the entity. Safe because every caller passes a per-request object it just
|
|
189
|
+
* deserialized from Redis or built from a queue job, never shared state.
|
|
190
|
+
*
|
|
191
|
+
* @param {Object} entry - the entity about to be serialized into a response
|
|
192
|
+
* @returns {Object} the same object, with credentials masked
|
|
193
|
+
*/
|
|
194
|
+
function maskSecrets(entry) {
|
|
195
|
+
if (!entry || typeof entry !== 'object') {
|
|
196
|
+
return entry;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
for (const key of URL_SECRET_KEYS) {
|
|
200
|
+
if (entry[key]) {
|
|
201
|
+
entry[key] = maskUrlPassword(entry[key]);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
for (const key of HEADER_SECRET_KEYS) {
|
|
206
|
+
if (entry[key]) {
|
|
207
|
+
entry[key] = maskCustomHeaders(entry[key]);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// smtpStatus on an account, lastError on a gateway, progress.error on a queue entry.
|
|
212
|
+
//
|
|
213
|
+
// `lastErrorState` is the account's, and it is a separate entry rather than a rename because the
|
|
214
|
+
// two really are different keys: Account.unserializeAccountData() parses the connection error
|
|
215
|
+
// under `lastErrorState`, and the getter only renames it to `lastError` on the way out, well
|
|
216
|
+
// after this runs. Masking one name and not the other left the account getter publishing the
|
|
217
|
+
// proxy URL of the failed connection while the reviewer read a mask call that looked like it
|
|
218
|
+
// covered it.
|
|
219
|
+
for (const container of ['smtpStatus', 'lastError', 'lastErrorState', 'error', 'progress']) {
|
|
220
|
+
maskNetworkRouting(entry[container]);
|
|
221
|
+
if (entry[container] && typeof entry[container] === 'object') {
|
|
222
|
+
maskNetworkRouting(entry[container].error);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return entry;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Refuses a submission that redirects the connection, when the credential making it is narrowed.
|
|
231
|
+
*
|
|
232
|
+
* `proxy` in a submit payload overrides the account's own route and the instance-wide one
|
|
233
|
+
* (applyProxyConfig in lib/email-client/message-builder.js takes the payload first), and the SMTP
|
|
234
|
+
* session it redirects still carries the account's decrypted username and password. A SOCKS
|
|
235
|
+
* endpoint therefore decides where the connection lands, can answer as the mail server, and - with
|
|
236
|
+
* no STARTTLS advertised and nothing requiring it - collects AUTH in plaintext. So the field turns
|
|
237
|
+
* "may send mail" into "may read the credential that sends the mail".
|
|
238
|
+
*
|
|
239
|
+
* That is the same reasoning that put the gateway writes in the never-grantable `admin` group:
|
|
240
|
+
* reading a stored credential back is masked, sending it somewhere is not. It applies here because
|
|
241
|
+
* `submit` is a grantable group, so the narrowing has to hold the line the route grant cannot.
|
|
242
|
+
*
|
|
243
|
+
* Only for narrowed tokens. An unnarrowed one already reaches PUT /v1/account/{account} and can
|
|
244
|
+
* point the account's own proxy wherever it likes, so refusing it here would cost a documented
|
|
245
|
+
* capability and buy nothing.
|
|
246
|
+
*
|
|
247
|
+
* The refusal is not written to the per-token audit log, deliberately. That trail records what a
|
|
248
|
+
* credential was ADMITTED to attempt - it is written by the auth strategy, before payload validation
|
|
249
|
+
* and the handler, so a 400 or a 404 does not appear in it either, and this is a handler-level
|
|
250
|
+
* refusal of one field. It does reach the application log: handleError() logs the 403 through
|
|
251
|
+
* `request.logger`, which the strategy has already bound the token id to.
|
|
252
|
+
*
|
|
253
|
+
* @param {Object} request - the Hapi request
|
|
254
|
+
*/
|
|
255
|
+
function assertNoNetworkOverride(request) {
|
|
256
|
+
if (!request.payload || !request.payload.proxy) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Asked of the module that enforces the narrowing rather than by testing `permissions` for
|
|
261
|
+
// truthiness, so `{}` and an unreadable record are read here exactly as they are at the
|
|
262
|
+
// strategy. `artifacts` is the token record the api-token strategy resolved.
|
|
263
|
+
if (!tokenPermissions.inspect(request.auth && request.auth.artifacts).narrowed) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
throw Boom.forbidden('A token with restricted permissions can not override the connection route');
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
module.exports = {
|
|
271
|
+
handleError,
|
|
272
|
+
logApiError,
|
|
273
|
+
throwNotFound,
|
|
274
|
+
flattenOAuthAppMeta,
|
|
275
|
+
maskCustomHeaders,
|
|
276
|
+
maskUrlPassword,
|
|
277
|
+
maskSecrets,
|
|
278
|
+
assertNoNetworkOverride,
|
|
279
|
+
MASKED,
|
|
280
|
+
MASK_NOTE
|
|
281
|
+
};
|