@jwilleke/ngdpbase-types 5.43.0 → 5.44.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/lib/src/context/ApiContext.d.ts +10 -3
- package/lib/src/context/ApiContext.js +36 -3
- package/lib/src/ice/runExport.d.ts +8 -3
- package/lib/src/ice/searchExportSource.d.ts +44 -0
- package/lib/src/ice/types.d.ts +6 -0
- package/lib/src/managers/AttachmentManager.d.ts +11 -0
- package/lib/src/managers/AuditManager.d.ts +0 -1
- package/lib/src/managers/AuthManager.d.ts +38 -0
- package/lib/src/managers/AuthManager.js +84 -12
- package/lib/src/managers/BackupManager.d.ts +9 -2
- package/lib/src/managers/BackupManager.js +42 -19
- package/lib/src/managers/BaseManager.d.ts +17 -3
- package/lib/src/managers/BaseManager.js +12 -8
- package/lib/src/managers/ConfigurationManager.d.ts +13 -0
- package/lib/src/managers/ConsentManager.d.ts +1 -1
- package/lib/src/managers/DatabaseManager.js +17 -8
- package/lib/src/managers/EmailManager.d.ts +1 -1
- package/lib/src/managers/ExportManager.d.ts +1 -44
- package/lib/src/managers/ExportManager.js +3 -115
- package/lib/src/managers/ImportManager.d.ts +7 -0
- package/lib/src/managers/PageManager.d.ts +9 -0
- package/lib/src/managers/PolicyEvaluator.d.ts +113 -30
- package/lib/src/managers/ThemeManager.d.ts +20 -1
- package/lib/src/providers/FileLoggingProvider.d.ts +12 -1
- package/lib/src/providers/FileLoggingProvider.js +37 -4
- package/lib/src/security/PolicyDecisionPoint.d.ts +50 -3
- package/lib/src/security/PolicyInformationPoint.d.ts +27 -1
- package/lib/src/security/ownedRecords.d.ts +69 -0
- package/lib/src/security/signedOutWrites.d.ts +69 -0
- package/lib/src/security/signedOutWrites.js +146 -0
- package/lib/src/types/Policy.d.ts +26 -30
- package/lib/src/utils/addonConfigLayer.d.ts +6 -3
- package/lib/src/utils/addonConfigLayer.js +61 -3
- package/lib/src/utils/addonHost.d.ts +25 -0
- package/lib/src/utils/addonHost.js +29 -1
- package/lib/src/utils/availability.d.ts +15 -0
- package/lib/src/utils/availability.js +88 -0
- package/lib/src/utils/pageTitleConflict.d.ts +32 -0
- package/lib/src/utils/pageWritePolicies.d.ts +48 -29
- package/lib/src/utils/plainAttention.d.ts +19 -0
- package/lib/src/utils/plainAttention.js +18 -0
- package/lib/src/utils/policyAttributes.d.ts +113 -22
- package/lib/src/utils/policyAttributes.js +228 -43
- package/lib/src/utils/roleGrants.d.ts +1 -1
- package/package.json +7 -7
|
@@ -1,39 +1,74 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The vocabulary of a policy `condition` (#2261): attribute types, the
|
|
3
|
-
* operator table, the nesting limit, and how one comparison is decided.
|
|
4
|
-
* Pure: no I/O, no manager. The evaluator and the validator both import it,
|
|
5
|
-
* so the set of operators lives here and nowhere else.
|
|
6
|
-
*/
|
|
7
1
|
/** The types an attribute can be declared with. */
|
|
8
2
|
export const ATTRIBUTE_TYPES = ['string', 'integer', 'boolean', 'identity', 'list'];
|
|
9
3
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
4
|
+
* The datatypes a condition may name: the XACML 3.0 JSON profile's short
|
|
5
|
+
* names. Only `string`, `integer` and `boolean` have a function today, so a
|
|
6
|
+
* condition naming any other is refused as a datatype its function does not take.
|
|
7
|
+
*/
|
|
8
|
+
export const DATATYPES = ['string', 'integer', 'boolean', 'double', 'date', 'time', 'dateTime', 'anyURI'];
|
|
9
|
+
/**
|
|
10
|
+
* How deep a condition may nest. Every function node counts, arguments that
|
|
11
|
+
* are attributes or values do not, so `or` > `and` > `not` > `string-equal` is 4
|
|
12
|
+
* and one more level is refused.
|
|
12
13
|
*/
|
|
13
14
|
export const MAX_CONDITION_DEPTH = 4;
|
|
14
15
|
/**
|
|
15
16
|
* How wide a condition may be (#2261). Depth alone leaves the tree as wide as
|
|
16
17
|
* a config file can make it, and the evaluator walks it for every page a
|
|
17
|
-
* listing or search asks about. A literal `
|
|
18
|
-
*
|
|
18
|
+
* listing or search asks about. A literal `value` list in an `is-in`, the
|
|
19
|
+
* arguments of one `and` or `or`, and the function nodes of the whole condition
|
|
20
|
+
* are each capped.
|
|
19
21
|
*/
|
|
20
22
|
export const MAX_IN_ITEMS = 256;
|
|
21
23
|
export const MAX_GROUP_CHILDREN = 256;
|
|
22
24
|
export const MAX_CONDITION_NODES = 512;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
'
|
|
30
|
-
'
|
|
25
|
+
/**
|
|
26
|
+
* The functions that compare two arguments, by XACML 3.0 name (core spec,
|
|
27
|
+
* appendix A.3), in lowercase. `X-is-in` takes a value, then a bag: an attribute
|
|
28
|
+
* that is a list, or a literal whose `value` is an array.
|
|
29
|
+
*/
|
|
30
|
+
export const COMPARISON_FUNCTIONS = {
|
|
31
|
+
'string-equal': { type: 'string', kind: 'equal' },
|
|
32
|
+
'integer-equal': { type: 'integer', kind: 'equal' },
|
|
33
|
+
'boolean-equal': { type: 'boolean', kind: 'equal' },
|
|
34
|
+
'string-is-in': { type: 'string', kind: 'is-in' },
|
|
35
|
+
'integer-is-in': { type: 'integer', kind: 'is-in' },
|
|
36
|
+
'integer-greater-than': { type: 'integer', kind: 'greater-than' },
|
|
37
|
+
'integer-greater-than-or-equal': { type: 'integer', kind: 'greater-than-or-equal' },
|
|
38
|
+
'integer-less-than': { type: 'integer', kind: 'less-than' },
|
|
39
|
+
'integer-less-than-or-equal': { type: 'integer', kind: 'less-than-or-equal' }
|
|
31
40
|
};
|
|
32
|
-
/** The
|
|
33
|
-
export const
|
|
34
|
-
export const
|
|
35
|
-
/** Every
|
|
36
|
-
export const
|
|
41
|
+
/** The functions that combine conditions: XACML's logical functions. `not` takes one condition, these take a list. */
|
|
42
|
+
export const GROUP_FUNCTIONS = ['and', 'or'];
|
|
43
|
+
export const NOT_FUNCTION = 'not';
|
|
44
|
+
/** Every function, in the order the validator lists them. */
|
|
45
|
+
export const CONDITION_FUNCTIONS = [...Object.keys(COMPARISON_FUNCTIONS), ...GROUP_FUNCTIONS, NOT_FUNCTION];
|
|
46
|
+
/** The keys of an argument: an attribute or a literal, and its datatype. */
|
|
47
|
+
export const OPERAND_KEYS = ['attributeid', 'value', 'datatype'];
|
|
48
|
+
/**
|
|
49
|
+
* The shape before #2330, key by key, and what replaces it, so the validator
|
|
50
|
+
* can say what to write. Not read by the evaluator: an old condition never holds.
|
|
51
|
+
*/
|
|
52
|
+
export const LEGACY_CONDITION_KEYS = {
|
|
53
|
+
attribute: '{ "attributeid": …, "datatype": … } as an argument of a function',
|
|
54
|
+
equals: 'string-equal, integer-equal or boolean-equal',
|
|
55
|
+
'not-equals': 'not around string-equal, integer-equal or boolean-equal',
|
|
56
|
+
in: 'string-is-in or integer-is-in',
|
|
57
|
+
'greater-or-equal': 'integer-greater-than-or-equal',
|
|
58
|
+
'less-or-equal': 'integer-less-than-or-equal',
|
|
59
|
+
'any-of': 'or',
|
|
60
|
+
'all-of': 'and'
|
|
61
|
+
};
|
|
62
|
+
/** The one example the validator shows for the old shape. */
|
|
63
|
+
export const CONDITION_EXAMPLE = '{ "string-equal": [ { "attributeid": "subject:department-id", "datatype": "string" }, { "value": "sales", "datatype": "string" } ] }';
|
|
64
|
+
/** The datatype an attribute of a declared type is referenced with: an identity is a string. A list has the datatype of its entries. */
|
|
65
|
+
export function datatypeOf(attributeType) {
|
|
66
|
+
if (attributeType === 'identity')
|
|
67
|
+
return 'string';
|
|
68
|
+
if (attributeType === 'list')
|
|
69
|
+
return null;
|
|
70
|
+
return attributeType;
|
|
71
|
+
}
|
|
37
72
|
/** The type a literal value has, or `null` when it is not a usable literal. */
|
|
38
73
|
export function literalType(value) {
|
|
39
74
|
if (typeof value === 'string')
|
|
@@ -76,32 +111,46 @@ export function valueFits(attributeType, value) {
|
|
|
76
111
|
}
|
|
77
112
|
/**
|
|
78
113
|
* Decides one comparison once both sides are read. `undefined` is unknown: a
|
|
79
|
-
* side that is missing, or not of a type the
|
|
114
|
+
* side that is missing, or not of a type the function can compare. Both sides
|
|
80
115
|
* must be the same kind of value (a string, a boolean or a whole number), so
|
|
81
|
-
* "5" never equals 5 and NaN never compares. `in` takes an array, or a Set the
|
|
116
|
+
* "5" never equals 5 and NaN never compares. `is-in` takes an array, or a Set the
|
|
82
117
|
* evaluator built from a literal list; every entry of an array must be the
|
|
83
118
|
* kind of value on the left. An empty string is a value, not a missing one.
|
|
84
119
|
*/
|
|
85
|
-
export function compareLeaf(
|
|
120
|
+
export function compareLeaf(kind, left, right) {
|
|
86
121
|
if (!isComparable(left))
|
|
87
122
|
return undefined;
|
|
88
|
-
switch (
|
|
89
|
-
case '
|
|
123
|
+
switch (kind) {
|
|
124
|
+
case 'equal':
|
|
90
125
|
return isComparable(right) && typeof right === typeof left ? left === right : undefined;
|
|
91
|
-
case '
|
|
92
|
-
return isComparable(right) && typeof right === typeof left ? left !== right : undefined;
|
|
93
|
-
case 'in':
|
|
126
|
+
case 'is-in':
|
|
94
127
|
if (right instanceof Set)
|
|
95
128
|
return right.has(left);
|
|
96
129
|
return Array.isArray(right) && right.every((v) => isComparable(v) && typeof v === typeof left) ? right.includes(left) : undefined;
|
|
97
|
-
case 'greater-
|
|
130
|
+
case 'greater-than':
|
|
131
|
+
return typeof left === 'number' && typeof right === 'number' && Number.isInteger(right) ? left > right : undefined;
|
|
132
|
+
case 'greater-than-or-equal':
|
|
98
133
|
return typeof left === 'number' && typeof right === 'number' && Number.isInteger(right) ? left >= right : undefined;
|
|
99
|
-
case 'less-
|
|
134
|
+
case 'less-than':
|
|
135
|
+
return typeof left === 'number' && typeof right === 'number' && Number.isInteger(right) ? left < right : undefined;
|
|
136
|
+
case 'less-than-or-equal':
|
|
100
137
|
return typeof left === 'number' && typeof right === 'number' && Number.isInteger(right) ? left <= right : undefined;
|
|
101
138
|
default:
|
|
102
139
|
return undefined;
|
|
103
140
|
}
|
|
104
141
|
}
|
|
142
|
+
/** The key that names how rules are combined (#2330). */
|
|
143
|
+
export const RULE_COMBINING_ALGORITHM_KEY = 'ngdpbase.access.rule-combining-algorithm';
|
|
144
|
+
/** The only algorithm the evaluator implements; XACML's name for it. */
|
|
145
|
+
export const SUPPORTED_COMBINING_ALGORITHMS = ['deny-overrides'];
|
|
146
|
+
/** What Admin → Configuration says about the algorithm. */
|
|
147
|
+
export const DENY_OVERRIDES_EXPLANATION = 'Any matching deny wins. Order and priority don\'t matter.';
|
|
148
|
+
/** What is wrong with the value of `ngdpbase.access.rule-combining-algorithm`, or `null`. Used on save, on load and at boot. */
|
|
149
|
+
export function combiningAlgorithmProblem(value) {
|
|
150
|
+
if (typeof value === 'string' && SUPPORTED_COMBINING_ALGORITHMS.includes(value))
|
|
151
|
+
return null;
|
|
152
|
+
return `${RULE_COMBINING_ALGORITHM_KEY} is ${JSON.stringify(value) ?? 'not set'}; the only value accepted is ${SUPPORTED_COMBINING_ALGORITHMS.map((a) => `"${a}"`).join(', ')}`;
|
|
153
|
+
}
|
|
105
154
|
/** `value` as an assurance level, or `undefined` when it is not 1, 2 or 3. Never coerces. */
|
|
106
155
|
export function toAal(value) {
|
|
107
156
|
return value === 1 || value === 2 || value === 3 ? value : undefined;
|
|
@@ -178,17 +227,28 @@ export function declaredSubjectAttributes(raw) {
|
|
|
178
227
|
* declaration `subjectDeclarationProblem` refuses. Used on save, on load and at boot.
|
|
179
228
|
*/
|
|
180
229
|
export function subjectAttributesProblems(raw, sensitive) {
|
|
230
|
+
return subjectAttributesFindings(raw, sensitive).map((f) => f.log);
|
|
231
|
+
}
|
|
232
|
+
/** {@link subjectAttributesProblems}, each also in plain words for the needs-attention entry. */
|
|
233
|
+
export function subjectAttributesFindings(raw, sensitive) {
|
|
181
234
|
if (raw === null || raw === undefined)
|
|
182
235
|
return [];
|
|
183
|
-
if (typeof raw !== 'object' || Array.isArray(raw))
|
|
184
|
-
return [
|
|
236
|
+
if (typeof raw !== 'object' || Array.isArray(raw)) {
|
|
237
|
+
return [{
|
|
238
|
+
log: 'ngdpbase.access.subject-attributes must be an object of attribute name to { type, from }',
|
|
239
|
+
plain: 'The list of user details that rules can check is not in a form the site can read, so none of them work. Fix or clear that list in Admin → Configuration.'
|
|
240
|
+
}];
|
|
241
|
+
}
|
|
185
242
|
return Object.entries(raw).flatMap(([name, decl]) => {
|
|
186
243
|
const pinned = Object.hasOwn(PINNED_SUBJECT_ATTRIBUTES, name) ? PINNED_SUBJECT_ATTRIBUTES[name] : undefined;
|
|
187
244
|
if (pinned) {
|
|
188
245
|
const same = !!decl && typeof decl === 'object' && decl.type === pinned.type && decl.from === pinned.from;
|
|
189
|
-
return same ? [] : [
|
|
246
|
+
return same ? [] : [{
|
|
247
|
+
log: `subject attribute '${name}' in ngdpbase.access.subject-attributes cannot be redefined: it is built in (type ${pinned.type}, from ${pinned.from}) and keeps that meaning; remove it`,
|
|
248
|
+
plain: `The user detail '${name}' is built into the site and cannot be redefined, so your version is ignored. Remove it from the list of user details in Admin → Configuration.`
|
|
249
|
+
}];
|
|
190
250
|
}
|
|
191
|
-
const problem =
|
|
251
|
+
const problem = subjectDeclarationFinding(name, decl, sensitive);
|
|
192
252
|
return problem ? [problem] : [];
|
|
193
253
|
});
|
|
194
254
|
}
|
|
@@ -199,21 +259,146 @@ export function subjectAttributesProblems(raw, sensitive) {
|
|
|
199
259
|
* like). Said so a condition naming it is refused rather than silently unknown.
|
|
200
260
|
*/
|
|
201
261
|
export function subjectDeclarationProblem(name, decl, sensitive) {
|
|
262
|
+
return subjectDeclarationFinding(name, decl, sensitive)?.log ?? null;
|
|
263
|
+
}
|
|
264
|
+
/** {@link subjectDeclarationProblem}, also in plain words. */
|
|
265
|
+
function subjectDeclarationFinding(name, decl, sensitive) {
|
|
202
266
|
const where = `subject attribute '${name}' in ngdpbase.access.subject-attributes`;
|
|
267
|
+
const plain = `The user detail '${name}' is not set up correctly, so a rule that checks it will not work. Fix it, or remove it, in the list of user details in Admin → Configuration.`;
|
|
203
268
|
if (!decl || typeof decl !== 'object')
|
|
204
|
-
return `${where} must be an object with a type and a from
|
|
269
|
+
return { log: `${where} must be an object with a type and a from`, plain };
|
|
205
270
|
if (!ATTRIBUTE_TYPES.includes(decl.type))
|
|
206
|
-
return `${where} has type ${JSON.stringify(decl.type)}; use one of ${ATTRIBUTE_TYPES.join(', ')}
|
|
271
|
+
return { log: `${where} has type ${JSON.stringify(decl.type)}; use one of ${ATTRIBUTE_TYPES.join(', ')}`, plain };
|
|
207
272
|
const from = decl.from;
|
|
208
273
|
const source = typeof from === 'string' ? SUBJECT_SOURCES.find((s) => from === s || (s !== 'sign-in' && from.startsWith(s))) : undefined;
|
|
209
274
|
if (!source)
|
|
210
|
-
return `${where} reads from ${JSON.stringify(from)}; start it with ${SUBJECT_SOURCES.join(', ')}
|
|
275
|
+
return { log: `${where} reads from ${JSON.stringify(from)}; start it with ${SUBJECT_SOURCES.join(', ')}`, plain };
|
|
211
276
|
if (source !== 'sign-in') {
|
|
212
277
|
const field = from.slice(source.length);
|
|
213
278
|
if (!field)
|
|
214
|
-
return `${where} reads from '${source}' with no field; write ${source}<field
|
|
215
|
-
if (sensitive.includes(field))
|
|
216
|
-
return
|
|
279
|
+
return { log: `${where} reads from '${source}' with no field; write ${source}<field>`, plain };
|
|
280
|
+
if (sensitive.includes(field)) {
|
|
281
|
+
return {
|
|
282
|
+
log: `'${source}${field}' cannot be used in a condition`,
|
|
283
|
+
plain: `The user detail '${name}' reads private account data, which a rule may not check. Remove it from the list of user details in Admin → Configuration.`
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* A declaration map as written, every `$NAME` left unresolved, or `null` when
|
|
291
|
+
* it cannot be read. Declarations are read this way so a `$NAME` in one is
|
|
292
|
+
* judged and reported as written and an environment variable's value never
|
|
293
|
+
* reaches a message or a log line; a throwing read (an unset variable) is
|
|
294
|
+
* `null`, not an exception.
|
|
295
|
+
*/
|
|
296
|
+
export function readDeclaredAsWritten(config, key) {
|
|
297
|
+
if (!config)
|
|
298
|
+
return null;
|
|
299
|
+
try {
|
|
300
|
+
// No unresolved read means no way to avoid resolving `$NAME`, so read nothing.
|
|
301
|
+
return typeof config.getUnresolvedProperty === 'function' ? config.getUnresolvedProperty(key, null) : null;
|
|
302
|
+
}
|
|
303
|
+
catch {
|
|
304
|
+
return null;
|
|
217
305
|
}
|
|
306
|
+
}
|
|
307
|
+
/** Where an environment attribute may be read from: `schedule:<name>` or `config:<key>` (#2261 slice 4). */
|
|
308
|
+
export const ENVIRONMENT_SOURCES = ['schedule:', 'config:'];
|
|
309
|
+
/** The environment attributes a site declares. Anything not an object is ignored. */
|
|
310
|
+
export function declaredEnvironmentAttributes(raw) {
|
|
311
|
+
return raw && typeof raw === 'object' && !Array.isArray(raw) ? raw : {};
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* What is wrong with an environment attribute's declaration, or `null`: a
|
|
315
|
+
* `type` that is not `boolean` (both sources yield a boolean and nothing
|
|
316
|
+
* else), a `from` that is not `schedule:<name>` or `config:<key>`, or one with
|
|
317
|
+
* no name or key after the prefix. Any configuration key may be read, secrets
|
|
318
|
+
* included (#2261): a condition can only compare the value, and the value is
|
|
319
|
+
* never written to a log, an audit record or a message.
|
|
320
|
+
*/
|
|
321
|
+
export function environmentDeclarationProblem(name, decl) {
|
|
322
|
+
return environmentDeclarationFinding(name, decl)?.log ?? null;
|
|
323
|
+
}
|
|
324
|
+
/** {@link environmentDeclarationProblem}, also in plain words. */
|
|
325
|
+
function environmentDeclarationFinding(name, decl) {
|
|
326
|
+
const where = `environment attribute '${name}' in ngdpbase.access.environment-attributes`;
|
|
327
|
+
const plain = `The check '${name}' (for rules that depend on a schedule or a setting) is not set up correctly, so a rule that uses it will not work. Fix it, or remove it, in the list of checks in Admin → Configuration.`;
|
|
328
|
+
if (!decl || typeof decl !== 'object')
|
|
329
|
+
return { log: `${where} must be an object with a type and a from`, plain };
|
|
330
|
+
if (decl.type !== 'boolean')
|
|
331
|
+
return { log: `${where} has type ${JSON.stringify(decl.type)}; schedule: and config: attributes are boolean only, so use "boolean"`, plain };
|
|
332
|
+
const from = decl.from;
|
|
333
|
+
const source = typeof from === 'string' ? ENVIRONMENT_SOURCES.find((s) => from.startsWith(s)) : undefined;
|
|
334
|
+
if (!source)
|
|
335
|
+
return { log: `${where} reads from ${JSON.stringify(from)}; start it with ${ENVIRONMENT_SOURCES.join(' or ')}`, plain };
|
|
336
|
+
if (!from.slice(source.length))
|
|
337
|
+
return { log: `${where} reads from '${source}' with no ${source === 'schedule:' ? 'schedule name' : 'key'}; write ${source}<${source === 'schedule:' ? 'name' : 'key'}>`, plain };
|
|
218
338
|
return null;
|
|
219
339
|
}
|
|
340
|
+
/**
|
|
341
|
+
* What is wrong with the value of `ngdpbase.access.environment-attributes`
|
|
342
|
+
* itself, one message each: not an object, or a declaration
|
|
343
|
+
* {@link environmentDeclarationProblem} refuses. Used on save, on load and at boot.
|
|
344
|
+
*/
|
|
345
|
+
export function environmentAttributesProblems(raw) {
|
|
346
|
+
return environmentAttributesFindings(raw).map((f) => f.log);
|
|
347
|
+
}
|
|
348
|
+
/** {@link environmentAttributesProblems}, each also in plain words for the needs-attention entry. */
|
|
349
|
+
export function environmentAttributesFindings(raw) {
|
|
350
|
+
if (raw === null || raw === undefined)
|
|
351
|
+
return [];
|
|
352
|
+
if (typeof raw !== 'object' || Array.isArray(raw)) {
|
|
353
|
+
return [{
|
|
354
|
+
log: 'ngdpbase.access.environment-attributes must be an object of attribute name to { type, from }',
|
|
355
|
+
plain: 'The list of checks that depend on a schedule or a setting is not in a form the site can read, so none of them work. Fix or clear that list in Admin → Configuration.'
|
|
356
|
+
}];
|
|
357
|
+
}
|
|
358
|
+
return Object.entries(raw).flatMap(([name, decl]) => {
|
|
359
|
+
const problem = environmentDeclarationFinding(name, decl);
|
|
360
|
+
return problem ? [problem] : [];
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* What the old plural `conditions` array's entry types become in the single `condition` (#2334).
|
|
365
|
+
* Only a user-attribute entry with an equality operator (`==` or `===`) has an equivalent: a string comparison.
|
|
366
|
+
*/
|
|
367
|
+
const CONDITIONS_DECLARATION = '{ "department": { "type": "string", "from": "profile:department" } }';
|
|
368
|
+
const CONDITIONS_EXAMPLE = '{ "string-equal": [ { "attributeid": "subject:department", "datatype": "string" }, { "value": "IT", "datatype": "string" } ] }';
|
|
369
|
+
/** The policies that carry a non-empty old plural `conditions` array, named by id or by position (#2334). An empty array limits nothing either way, so it is not named. */
|
|
370
|
+
function policiesWithOldConditions(policies) {
|
|
371
|
+
if (!Array.isArray(policies))
|
|
372
|
+
return [];
|
|
373
|
+
return [...policies.entries()]
|
|
374
|
+
.filter(([, p]) => {
|
|
375
|
+
const c = p?.conditions;
|
|
376
|
+
return Array.isArray(c) && c.length > 0;
|
|
377
|
+
})
|
|
378
|
+
.map(([i, p]) => `'${typeof p.id === 'string' ? p.id : `#${i + 1}`}'`);
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* The words an administrator sees (the needs-attention entry and the save message) when a policy carries
|
|
382
|
+
* the old plural `conditions` array, or null when none does (#2334). Plain words: no issue number, no JSON.
|
|
383
|
+
*/
|
|
384
|
+
export function unenforcedConditionsNotice(policies) {
|
|
385
|
+
const names = policiesWithOldConditions(policies);
|
|
386
|
+
if (names.length === 0)
|
|
387
|
+
return null;
|
|
388
|
+
const one = names.length === 1;
|
|
389
|
+
return `${one ? 'This rule has' : 'These rules have'} an old 'conditions' list that the site ignores, so it doesn't limit anyone: ${names.join(', ')}. Move ${one ? 'it' : 'each one'} into ${one ? 'the' : 'its'} rule's condition, or remove it.`;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* The start-up log line for the same policies, in full: the condition to write, the attribute
|
|
393
|
+
* declaration it needs, and the entry types with no equivalent (#2334). Null when none has one.
|
|
394
|
+
* Nothing in the decision path reads that array, so a rule written there limits no access.
|
|
395
|
+
*/
|
|
396
|
+
export function unenforcedConditionsLine(policies) {
|
|
397
|
+
const names = policiesWithOldConditions(policies);
|
|
398
|
+
if (names.length === 0)
|
|
399
|
+
return null;
|
|
400
|
+
return `${names.join(', ')} ${names.length === 1 ? 'has' : 'have'} a conditions array, which is not enforced: nothing reads it, so it limits no access. `
|
|
401
|
+
+ `Replace it with the single condition in the XACML form. A user-attribute entry with the == or === operator becomes ${CONDITIONS_EXAMPLE}, `
|
|
402
|
+
+ `which needs the attribute declared with a source in ngdpbase.access.subject-attributes, for example ${CONDITIONS_DECLARATION} (see docs/access-policies.md#subject-attributes). `
|
|
403
|
+
+ 'The other entry types (time-range, ip-range, context-attribute, session-attribute, environment, and user-attribute with any other operator) have no equivalent: a rule you need cannot be written yet, so do not rely on it (#2334)';
|
|
404
|
+
}
|
|
@@ -26,7 +26,7 @@ export interface RoleGrants {
|
|
|
26
26
|
}
|
|
27
27
|
/** A grant to one subject, with the policies that give it (#2067). */
|
|
28
28
|
export interface SubjectGrant extends RoleGrant {
|
|
29
|
-
/** The ids of the allow policies that give it,
|
|
29
|
+
/** The ids of the allow policies that give it, in id order. */
|
|
30
30
|
by: string[];
|
|
31
31
|
}
|
|
32
32
|
export interface SubjectGrants {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jwilleke/ngdpbase-types",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.44.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",
|
|
@@ -45,20 +45,20 @@
|
|
|
45
45
|
"dotenv": "^18.0.9",
|
|
46
46
|
"express": "^5.3.0",
|
|
47
47
|
"express-session": "^1.19.0",
|
|
48
|
-
"fast-xml-parser": "^5.
|
|
48
|
+
"fast-xml-parser": "^5.12.0",
|
|
49
49
|
"fs-extra": "^11.4.1",
|
|
50
50
|
"ipaddr.js": "^2.5.0",
|
|
51
|
-
"jose": "^6.2.
|
|
52
|
-
"linkedom": "^0.18.
|
|
51
|
+
"jose": "^6.2.15",
|
|
52
|
+
"linkedom": "^0.18.15",
|
|
53
53
|
"markdown-it": "^14.3.3",
|
|
54
54
|
"minisearch": "7.2.0",
|
|
55
|
-
"mmdb-lib": "^3.0.
|
|
55
|
+
"mmdb-lib": "^3.0.4",
|
|
56
56
|
"multer": "^2.4.0",
|
|
57
|
-
"otpauth": "^9.
|
|
57
|
+
"otpauth": "^9.6.0",
|
|
58
58
|
"qrcode": "^1.5.4",
|
|
59
59
|
"rrule-temporal": "2.2.8",
|
|
60
60
|
"tar": "^7.5.22",
|
|
61
|
-
"temporal-polyfill": "1.0.
|
|
61
|
+
"temporal-polyfill": "1.0.8",
|
|
62
62
|
"winston": "^3.17.0"
|
|
63
63
|
}
|
|
64
64
|
}
|