@jwilleke/ngdpbase-types 5.30.0 → 5.31.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/README.md +1 -1
- package/lib/packages/ngdpbase-types/index.d.ts +5 -4
- package/lib/src/context/JobContext.d.ts +9 -0
- package/lib/src/context/JobContext.js +3 -1
- package/lib/src/context/bootActions.js +2 -0
- package/lib/src/ice/fileHandling.d.ts +24 -2
- package/lib/src/ice/originalKeep.d.ts +40 -0
- package/lib/src/ice/types.d.ts +33 -1
- package/lib/src/managers/AttachmentManager.d.ts +12 -8
- package/lib/src/managers/BackgroundJobManager.d.ts +17 -0
- package/lib/src/managers/IdentityManager.d.ts +64 -4
- package/lib/src/managers/ImportManager.d.ts +2 -5
- package/lib/src/managers/OrganizationManager.d.ts +9 -5
- package/lib/src/managers/PolicyEvaluator.d.ts +7 -0
- package/lib/src/managers/UserManager.d.ts +13 -0
- package/lib/src/providers/BaseAttachmentProvider.d.ts +2 -8
- package/lib/src/providers/BasicAttachmentProvider.d.ts +3 -8
- package/lib/src/security/PolicyDecisionPoint.d.ts +8 -0
- package/lib/src/security/PolicyInformationPoint.d.ts +1 -1
- package/lib/src/types/Person.d.ts +39 -6
- package/lib/src/types/Policy.d.ts +2 -2
- package/lib/src/types/Provider.d.ts +21 -0
- package/lib/src/utils/addonConfigLayer.d.ts +16 -0
- package/lib/src/utils/addonConfigLayer.js +40 -3
- package/lib/src/utils/addonHost.d.ts +21 -3
- package/lib/src/utils/addonHost.js +10 -4
- package/lib/src/utils/availability.d.ts +120 -0
- package/lib/src/utils/availability.js +174 -0
- package/lib/src/utils/keyedSerial.js +41 -0
- package/lib/src/utils/roleGrants.d.ts +18 -3
- package/lib/src/utils/sessionSecurity.d.ts +116 -0
- package/package.json +1 -1
|
@@ -24,12 +24,27 @@ export interface RoleGrants {
|
|
|
24
24
|
/** Actions a deny policy names for this role. */
|
|
25
25
|
denies: string[];
|
|
26
26
|
}
|
|
27
|
+
/** A grant to one subject, with the policies that give it (#2067). */
|
|
28
|
+
export interface SubjectGrant extends RoleGrant {
|
|
29
|
+
/** The ids of the allow policies that give it, lowest priority first. */
|
|
30
|
+
by: string[];
|
|
31
|
+
}
|
|
32
|
+
export interface SubjectGrants {
|
|
33
|
+
allows: SubjectGrant[];
|
|
34
|
+
/** Actions a deny policy names for this subject. */
|
|
35
|
+
denies: string[];
|
|
36
|
+
}
|
|
27
37
|
/**
|
|
28
38
|
* Every role a policy names, with what its policies allow and deny — the one
|
|
29
39
|
* reading of "what a role grants" (#1539): the user forms, the profile, the
|
|
30
40
|
* admin roles page and `PolicyDecisionPoint.rolePermissions` all come from
|
|
31
|
-
* here.
|
|
32
|
-
* a lower-priority allow gave and an allow above it gives it back — the order
|
|
33
|
-
* the evaluator's first-match-by-priority decides in.
|
|
41
|
+
* here.
|
|
34
42
|
*/
|
|
35
43
|
export declare function roleGrants(policies: readonly Policy[]): Record<string, RoleGrants>;
|
|
44
|
+
/**
|
|
45
|
+
* Every scheduled job a policy names (`{ "type": "job", "value": "<job id>" }`,
|
|
46
|
+
* #1999), with what its policies allow and deny and which policy gives each
|
|
47
|
+
* allow — the admin roles page's Jobs part (#2067). A job a policy names acts
|
|
48
|
+
* as itself and holds only these. Display only, like {@link roleGrants}.
|
|
49
|
+
*/
|
|
50
|
+
export declare function jobGrants(policies: readonly Policy[]): Record<string, SubjectGrants>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* resolveSessionSecurity — keep `session.secure` and `trust proxy` consistent (#1046).
|
|
3
|
+
*
|
|
4
|
+
* #1043 made the session cookie `secure` actually turn on in production. On
|
|
5
|
+
* every HTTPS deployment that terminates TLS upstream — Cloudflare, an ingress,
|
|
6
|
+
* a tunnel — that silently broke login:
|
|
7
|
+
*
|
|
8
|
+
* 1. `secure` resolves true, so express-session will only emit `Set-Cookie`
|
|
9
|
+
* on a connection it believes is https.
|
|
10
|
+
* 2. `trust proxy` defaults to false, so Express reads the raw socket and
|
|
11
|
+
* believes the connection is plain http. It is not wrong — the hop from
|
|
12
|
+
* the proxy really is http; it simply has not been told to read
|
|
13
|
+
* X-Forwarded-Proto.
|
|
14
|
+
* 3. No session cookie ever reaches the browser. Every following request
|
|
15
|
+
* builds a fresh session, so `req.session.csrfToken` is missing and the
|
|
16
|
+
* CSRF middleware answers `403 Forbidden — invalid CSRF token` — on
|
|
17
|
+
* `POST /login` included. Nobody can sign in.
|
|
18
|
+
*
|
|
19
|
+
* The two settings are not independent, so they are resolved together here.
|
|
20
|
+
* Turning on `secure` without `trust proxy` is not a working configuration;
|
|
21
|
+
* `secure` is the operator's stated intent to be behind TLS, and behind
|
|
22
|
+
* terminated TLS `trust proxy` is what makes Express able to see it.
|
|
23
|
+
*
|
|
24
|
+
* The operator's explicit choice still wins for both keys. The shipped
|
|
25
|
+
* app-default-config.json pins `ngdpbase.session.secure` and
|
|
26
|
+
* `ngdpbase.server.trust-proxy` to false, so a plain getProperty() read cannot
|
|
27
|
+
* tell "operator asked for false" from "nobody has said anything" — hence
|
|
28
|
+
* reading getCustomProperties() rather than the merged view.
|
|
29
|
+
*
|
|
30
|
+
* ## #1160 — native TLS breaks the assumption
|
|
31
|
+
*
|
|
32
|
+
* All of the above assumed `secure: true` meant TLS terminated UPSTREAM, so a
|
|
33
|
+
* proxy existed whose `X-Forwarded-Proto` Express had to be told to read. #1153
|
|
34
|
+
* made the server able to terminate TLS itself, and then there is no proxy —
|
|
35
|
+
* and trusting a forwarded header that nothing sets is worse than not trusting
|
|
36
|
+
* it. With `trust proxy` on and nothing in front, a caller can assert their own
|
|
37
|
+
* address and scheme, which the login throttle counts by and the audit log
|
|
38
|
+
* records.
|
|
39
|
+
*
|
|
40
|
+
* So the derivation now asks what is actually true rather than inferring from
|
|
41
|
+
* `secure` alone. The same applies to the misconfiguration warning: `secure`
|
|
42
|
+
* with `trust-proxy` explicitly false is the CORRECT configuration under native
|
|
43
|
+
* TLS, and warning about it would train an operator to ignore a warning that is
|
|
44
|
+
* load-bearing in the upstream case.
|
|
45
|
+
*/
|
|
46
|
+
/** Express's accepted `trust proxy` values: off, hop count, or a subnet list. */
|
|
47
|
+
export type TrustProxyValue = boolean | number | string;
|
|
48
|
+
/** What the resolution needs to know about the transport (#1160). */
|
|
49
|
+
export interface SessionSecurityContext {
|
|
50
|
+
/**
|
|
51
|
+
* True when this server terminates TLS itself (#1153).
|
|
52
|
+
*
|
|
53
|
+
* Defaults to false so every existing caller keeps its pre-#1160 behaviour
|
|
54
|
+
* rather than silently changing what it resolves.
|
|
55
|
+
*/
|
|
56
|
+
nativeTls?: boolean;
|
|
57
|
+
}
|
|
58
|
+
export interface SessionSecurity {
|
|
59
|
+
/** Value for the session cookie's `secure` flag. */
|
|
60
|
+
secure: boolean;
|
|
61
|
+
/** Value for `app.set('trust proxy', …)`. `false` means do not set it. */
|
|
62
|
+
trustProxy: TrustProxyValue;
|
|
63
|
+
/** True when `trustProxy` was derived from `secure` rather than configured. */
|
|
64
|
+
trustProxyDerived: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* True when the resolved pair cannot issue a session cookie behind
|
|
67
|
+
* terminated TLS — `secure` on with `trust proxy` explicitly off. Only
|
|
68
|
+
* reachable when the operator configured that combination by hand; the
|
|
69
|
+
* caller is expected to log it loudly rather than silently "fix" a stated
|
|
70
|
+
* choice.
|
|
71
|
+
*/
|
|
72
|
+
misconfigured: boolean;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Resolve the session cookie's `secure` flag and the matching `trust proxy`.
|
|
76
|
+
*
|
|
77
|
+
* `secure`: the operator's explicit boolean, else on when NODE_ENV is
|
|
78
|
+
* production. Inferring it from the request would get the terminated-TLS case
|
|
79
|
+
* exactly backwards, which is the case that matters.
|
|
80
|
+
*
|
|
81
|
+
* `trustProxy`: the operator's explicit value, else `true` whenever `secure`
|
|
82
|
+
* ends up on. `true` — rather than a hop count — because req.ip must come out
|
|
83
|
+
* as the end client. Under `1` behind Cloudflare, req.ip would resolve to the
|
|
84
|
+
* edge address shared by every visitor, and the login throttle's `ip:` bucket
|
|
85
|
+
* (#1044) would lock out all users at once on ten failures from anyone. An
|
|
86
|
+
* operator whose instance is also reachable directly should pin a hop count or
|
|
87
|
+
* a subnet list, since X-Forwarded-For is client-spoofable on that path.
|
|
88
|
+
*
|
|
89
|
+
* @param customProperties operator overrides only — NOT the merged config
|
|
90
|
+
* @param nodeEnv typically process.env.NODE_ENV
|
|
91
|
+
*/
|
|
92
|
+
export declare function resolveSessionSecurity(customProperties: Record<string, unknown> | null | undefined, nodeEnv: string | undefined, context?: SessionSecurityContext): SessionSecurity;
|
|
93
|
+
/**
|
|
94
|
+
* #2071 — what an administrator and a visitor are told when the session
|
|
95
|
+
* cookie cannot reach the browser, spelled once: the server log, the admin
|
|
96
|
+
* dashboard, the CSRF refusal and the login page all say this.
|
|
97
|
+
*/
|
|
98
|
+
export declare const SESSION_COOKIE_WITHHELD_MESSAGE: string;
|
|
99
|
+
/** The two request fields the check reads; express's Request has both. */
|
|
100
|
+
export interface SessionCookieRequest {
|
|
101
|
+
secure?: boolean;
|
|
102
|
+
session?: {
|
|
103
|
+
cookie?: {
|
|
104
|
+
secure?: unknown;
|
|
105
|
+
};
|
|
106
|
+
} | null;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* True when express-session will NOT send the session cookie on this request
|
|
110
|
+
* (#2071): the cookie is `secure` and the request is not https as Express
|
|
111
|
+
* sees it, after `trust proxy`. express-session makes exactly this check and
|
|
112
|
+
* then silently sends nothing, so the browser has no session, every POST
|
|
113
|
+
* meets a fresh one, and the CSRF middleware refuses it. A boolean read of
|
|
114
|
+
* two fields, cheap enough for every request.
|
|
115
|
+
*/
|
|
116
|
+
export declare function sessionCookieWithheld(req: SessionCookieRequest): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jwilleke/ngdpbase-types",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.31.0",
|
|
4
4
|
"description": "TypeScript types for ngdpbase add-ons, and a test kit of core's own values. A dev dependency, versioned with ngdpbase.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Jim Willeke",
|