@mistriwork/engine 1.0.0-rc.66 → 1.0.0-rc.67
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.
|
@@ -12,6 +12,12 @@ export interface Bound {
|
|
|
12
12
|
host: string;
|
|
13
13
|
port: number;
|
|
14
14
|
allowedHosts?: readonly string[];
|
|
15
|
+
/**
|
|
16
|
+
* Names beyond `allowedHosts` that change while the process runs (a suite's tenant hosts, which live in a table):
|
|
17
|
+
* asked with the Host header's name, lowercase and without a port. Beside the list, never instead of it; a
|
|
18
|
+
* listener with one is no more a trusted loopback client than one with a list.
|
|
19
|
+
*/
|
|
20
|
+
allowsHost?: (host: string) => boolean;
|
|
15
21
|
/** See `--auth-proxy-header`. */
|
|
16
22
|
identityHeader?: string;
|
|
17
23
|
/** See `--trust-proxy`: proxies the public form rate limit may believe about who they forwarded for. Never identity. */
|
|
@@ -165,6 +171,7 @@ export declare function identityFor(req: {
|
|
|
165
171
|
export declare function clientTrusted(bound: {
|
|
166
172
|
host: string;
|
|
167
173
|
allowedHosts?: readonly string[];
|
|
174
|
+
allowsHost?: Bound['allowsHost'];
|
|
168
175
|
}): boolean;
|
|
169
176
|
/**
|
|
170
177
|
* Why a connection target from an untrusted client is refused, or null when
|
|
@@ -321,7 +321,7 @@ export function identityFor(req, bound) {
|
|
|
321
321
|
* that takes a database *address* rather than a query.
|
|
322
322
|
*/
|
|
323
323
|
export function clientTrusted(bound) {
|
|
324
|
-
return LOOPBACK.test(bound.host) && !bound.allowedHosts?.length;
|
|
324
|
+
return LOOPBACK.test(bound.host) && !bound.allowedHosts?.length && !bound.allowsHost;
|
|
325
325
|
}
|
|
326
326
|
/**
|
|
327
327
|
* Why a connection target from an untrusted client is refused, or null when
|
|
@@ -390,7 +390,10 @@ export function hostRefusal(req, bound) {
|
|
|
390
390
|
bind could never pass its own check. */
|
|
391
391
|
const expected = `${bound.host.includes(':') && !bound.host.startsWith('[') ? `[${bound.host}]` : bound.host}:${bound.port}`;
|
|
392
392
|
const allowed = bound.allowedHosts ?? [];
|
|
393
|
-
if (!LOOPBACK.test(host) &&
|
|
393
|
+
if (!LOOPBACK.test(host) &&
|
|
394
|
+
host !== expected &&
|
|
395
|
+
!hostAllowed(host, allowed) &&
|
|
396
|
+
!bound.allowsHost?.(host.toLowerCase().replace(/:\d+$/, ''))) {
|
|
394
397
|
return (`Refused: this request arrived for host "${host}". ${product()} only answers on ${expected}.` +
|
|
395
398
|
` Add --allowed-host, or set ${envName('ALLOWED_HOSTS')}, to trust another name.`);
|
|
396
399
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mistriwork/engine",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.67",
|
|
4
4
|
"description": "The engine both products stand on: the adapters (SQLite, Postgres), the catalog, the query language, keyset pages, the HTTP kit and the shared rules. No React.",
|
|
5
5
|
"homepage": "https://mistriwork.dev",
|
|
6
6
|
"bugs": {
|