@webda/core 4.0.0-beta.4 → 4.0.0-beta.5
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/core/operations.d.ts.map +1 -1
- package/lib/core/operations.js +13 -11
- package/lib/core/operations.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/models/aclmodel.d.ts +32 -5
- package/lib/models/aclmodel.d.ts.map +1 -1
- package/lib/models/aclmodel.js +34 -9
- package/lib/models/aclmodel.js.map +1 -1
- package/lib/models/ownermodel.model.d.ts +25 -3
- package/lib/models/ownermodel.model.d.ts.map +1 -1
- package/lib/models/ownermodel.model.js +44 -9
- package/lib/models/ownermodel.model.js.map +1 -1
- package/lib/models/permissions.d.ts +236 -0
- package/lib/models/permissions.d.ts.map +1 -0
- package/lib/models/permissions.js +495 -0
- package/lib/models/permissions.js.map +1 -0
- package/lib/models/rolemodel.model.d.ts.map +1 -1
- package/lib/models/rolemodel.model.js +1 -2
- package/lib/models/rolemodel.model.js.map +1 -1
- package/lib/models/user.model.d.ts +12 -0
- package/lib/models/user.model.d.ts.map +1 -1
- package/lib/models/user.model.js +16 -0
- package/lib/models/user.model.js.map +1 -1
- package/lib/rest/restoperationstransport.service.d.ts.map +1 -1
- package/lib/rest/restoperationstransport.service.js +7 -5
- package/lib/rest/restoperationstransport.service.js.map +1 -1
- package/lib/services/audit.model.d.ts +2 -2
- package/lib/services/audit.model.d.ts.map +1 -1
- package/lib/services/audit.model.js +14 -5
- package/lib/services/audit.model.js.map +1 -1
- package/lib/services/binary.service.d.ts +42 -4
- package/lib/services/binary.service.d.ts.map +1 -1
- package/lib/services/binary.service.js +33 -13
- package/lib/services/binary.service.js.map +1 -1
- package/lib/services/domainservice.service.d.ts +74 -3
- package/lib/services/domainservice.service.d.ts.map +1 -1
- package/lib/services/domainservice.service.js +234 -57
- package/lib/services/domainservice.service.js.map +1 -1
- package/package.json +17 -13
- package/webda.module.json +3 -15
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
import { ComparisonExpression, LogicalExpression, QueryValidator } from "@webda/ql";
|
|
2
|
+
import { Model } from "@webda/models";
|
|
3
|
+
import { useLog } from "@webda/workout";
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
import * as WebdaError from "../errors/errors.js";
|
|
6
|
+
import { useModel } from "../application/hooks.js";
|
|
7
|
+
import { useDynamicService, useModelMetadata } from "../core/hooks.js";
|
|
8
|
+
/**
|
|
9
|
+
* The CryptoService, resolved at call time (a static import would make a cycle through the operations module)
|
|
10
|
+
* @returns the CryptoService
|
|
11
|
+
*/
|
|
12
|
+
function useCrypto() {
|
|
13
|
+
return useDynamicService("CryptoService");
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The static `canAct(context, action, object?)` of one model class
|
|
17
|
+
*
|
|
18
|
+
* When the class defines none (a plain object in a unit test, a class built without `@webda/models`), the base
|
|
19
|
+
* {@link Model.canAct} semantics apply: delegate to the instance `canAct(context, action)`, otherwise deny.
|
|
20
|
+
* @param clazz - the model class
|
|
21
|
+
* @returns the static check, bound to its class
|
|
22
|
+
*/
|
|
23
|
+
function staticCanActOf(clazz) {
|
|
24
|
+
if (typeof clazz?.canAct === "function") {
|
|
25
|
+
return (context, action, target) => clazz.canAct(context, action, target);
|
|
26
|
+
}
|
|
27
|
+
return (context, action, target) => Model.canAct(context, action, target);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The permission check of an object reached through a model class: the one framework entry point
|
|
31
|
+
*
|
|
32
|
+
* Stores are polymorphic: an object reached through a model class (the route or query class) may belong to a
|
|
33
|
+
* subclass with its own policy. The action is then allowed only when BOTH the reached class and the object's own
|
|
34
|
+
* class allow it, `ReachedModel.canAct(ctx, action, object)` first. When the two are the same class (or there is
|
|
35
|
+
* no object, as for a static action) the class is asked once.
|
|
36
|
+
* @param model - the model class the object is reached through, when known
|
|
37
|
+
* @param object - the object, if any
|
|
38
|
+
* @returns the check
|
|
39
|
+
*/
|
|
40
|
+
function staticCanAct(model, object) {
|
|
41
|
+
const own = object !== undefined && object !== null ? object.constructor : undefined;
|
|
42
|
+
const reached = model ?? own;
|
|
43
|
+
const classes = [reached];
|
|
44
|
+
if (typeof model === "function" && own && own !== model && own !== Object) {
|
|
45
|
+
if (!(object instanceof model)) {
|
|
46
|
+
// A row of an unrelated class (a misconfigured shared repository): it is not an object of the reached model
|
|
47
|
+
return () => `not a ${model.name}`;
|
|
48
|
+
}
|
|
49
|
+
classes.push(own);
|
|
50
|
+
}
|
|
51
|
+
const checks = classes.map(staticCanActOf);
|
|
52
|
+
if (checks.length === 1) {
|
|
53
|
+
return checks[0];
|
|
54
|
+
}
|
|
55
|
+
return async (context, action, target) => {
|
|
56
|
+
for (const check of checks) {
|
|
57
|
+
const allowed = await check(context, action, target);
|
|
58
|
+
if (allowed !== true) {
|
|
59
|
+
return allowed;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Whether a model class defines a static `canAct` of its own (not the base one)
|
|
67
|
+
* @param model - the model class
|
|
68
|
+
* @returns true when the static form is overridden
|
|
69
|
+
*/
|
|
70
|
+
export function hasStaticPermissionCheck(model) {
|
|
71
|
+
return typeof model?.canAct === "function" && model.canAct !== Model.canAct;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Whether a model class defines a permission check at all: a static `canAct` of its own (not the base one), or an
|
|
75
|
+
* instance `canAct`. A model with neither is refused on every transport. Subclasses with their own check do not
|
|
76
|
+
* open a class that has none: an object reached through a class must be allowed by that class too
|
|
77
|
+
* @param model - the model class
|
|
78
|
+
* @returns true when the model defines one of the two forms
|
|
79
|
+
*/
|
|
80
|
+
export function hasModelPermissionCheck(model) {
|
|
81
|
+
return hasStaticPermissionCheck(model) || typeof model?.prototype?.canAct === "function";
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Run a check, turning a thrown error into a refusal: an error must not answer differently from a refusal, or it
|
|
85
|
+
* would reveal that the object exists (non-HTTP errors are logged at WARN)
|
|
86
|
+
* @param check - the static canAct
|
|
87
|
+
* @param context - the caller context
|
|
88
|
+
* @param action - the action
|
|
89
|
+
* @param object - the object, if any
|
|
90
|
+
* @returns true when allowed, otherwise the refusal (a reason string or false)
|
|
91
|
+
*/
|
|
92
|
+
async function askPermission(check, context, action, object) {
|
|
93
|
+
try {
|
|
94
|
+
const allowed = await check(context, action, object);
|
|
95
|
+
if (allowed === true) {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
return allowed === false || allowed === undefined || allowed === null ? false : allowed;
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
if (!(err instanceof WebdaError.HttpError)) {
|
|
102
|
+
useLog("WARN", `canAct('${action}') failed on ${object?.constructor?.name ?? "model"}`, err);
|
|
103
|
+
}
|
|
104
|
+
return err?.message ?? false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Ask the model whether the current caller may perform `action` on an object
|
|
109
|
+
*
|
|
110
|
+
* The question goes through the static `canAct(context, action, object)` of the model class (see
|
|
111
|
+
* {@link Model.canAct}): the base implementation delegates to the object's instance `canAct`, and denies when there
|
|
112
|
+
* is none. `true` allows; anything else (`false`, a refusal reason string, `undefined`...) refuses, and so does a
|
|
113
|
+
* `canAct` that throws.
|
|
114
|
+
*
|
|
115
|
+
* @param object - the model instance (the new, unsaved object on create)
|
|
116
|
+
* @param context - the caller context
|
|
117
|
+
* @param action - the action name ("get", "create", "update", "delete", an action name or "attribute.action")
|
|
118
|
+
* @param model - the model class (defaults to the object's class)
|
|
119
|
+
* @returns true when allowed, otherwise the refusal (a reason string or false)
|
|
120
|
+
*/
|
|
121
|
+
export async function getModelPermission(object, context, action, model) {
|
|
122
|
+
return askPermission(staticCanAct(model, object), context, action, object);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Whether the current caller may perform `action` on a model instance (see {@link checkModelPermission}); it never
|
|
126
|
+
* throws
|
|
127
|
+
* @param object - the model instance
|
|
128
|
+
* @param context - the caller context
|
|
129
|
+
* @param action - the action name
|
|
130
|
+
* @param model - the model class (defaults to the object's class)
|
|
131
|
+
* @returns true when allowed
|
|
132
|
+
*/
|
|
133
|
+
export async function isModelActionAllowed(object, context, action, model) {
|
|
134
|
+
return (await getModelPermission(object, context, action, model)) === true;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Message of the NotFound error for a missing object, also used for an object the caller may not read
|
|
138
|
+
*/
|
|
139
|
+
export const NOT_FOUND_MESSAGE = "Object not found";
|
|
140
|
+
/**
|
|
141
|
+
* Load an object for an action as the caller: a missing object and an object the caller may not read throw the same
|
|
142
|
+
* `NotFound("Object not found")`; a readable object whose action is refused throws `Forbidden`
|
|
143
|
+
* @param model - the model class
|
|
144
|
+
* @param key - the primary key
|
|
145
|
+
* @param context - the caller context
|
|
146
|
+
* @param action - the action ("get" to only read)
|
|
147
|
+
* @returns the object
|
|
148
|
+
*/
|
|
149
|
+
export async function loadModelForAction(model, key, context, action) {
|
|
150
|
+
let object;
|
|
151
|
+
try {
|
|
152
|
+
object = await model.ref(key).get();
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
// Repositories throw when the object does not exist
|
|
156
|
+
}
|
|
157
|
+
if (!object || object.isDeleted?.()) {
|
|
158
|
+
throw new WebdaError.NotFound(NOT_FOUND_MESSAGE);
|
|
159
|
+
}
|
|
160
|
+
await checkModelPermission(object, context, action, model);
|
|
161
|
+
return object;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* The parent relation (`ModelParent`) of a model, if any
|
|
165
|
+
* @param model - the model class
|
|
166
|
+
* @returns the parent attribute and model identifier
|
|
167
|
+
*/
|
|
168
|
+
export function getParentRelation(model) {
|
|
169
|
+
try {
|
|
170
|
+
return useModelMetadata(model)?.Relations?.parent;
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
return undefined;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* A child can only be attached to a parent the caller may read: a missing parent and an unreadable one throw the same
|
|
178
|
+
* `NotFound("Object not found")`
|
|
179
|
+
* @param model - the child model class
|
|
180
|
+
* @param parentId - the parent primary key
|
|
181
|
+
* @param context - the caller context
|
|
182
|
+
*/
|
|
183
|
+
export async function checkModelParent(model, parentId, context) {
|
|
184
|
+
const parent = getParentRelation(model);
|
|
185
|
+
if (!parent || parentId === undefined || parentId === null || parentId === "") {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
let parentModel;
|
|
189
|
+
try {
|
|
190
|
+
parentModel = useModel(parent.model);
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
// Unknown parent model: treated as a missing parent
|
|
194
|
+
}
|
|
195
|
+
if (!parentModel) {
|
|
196
|
+
throw new WebdaError.NotFound(NOT_FOUND_MESSAGE);
|
|
197
|
+
}
|
|
198
|
+
await loadModelForAction(parentModel, parentId, context, "get");
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* When an update moves an object to another parent, the caller must be able to read the new parent
|
|
202
|
+
* @param model - the model class
|
|
203
|
+
* @param object - the stored object
|
|
204
|
+
* @param input - the sanitized update input
|
|
205
|
+
* @param context - the caller context
|
|
206
|
+
*/
|
|
207
|
+
export async function checkModelReparent(model, object, input, context) {
|
|
208
|
+
const parent = getParentRelation(model);
|
|
209
|
+
const value = parent ? input?.[parent.attribute] : undefined;
|
|
210
|
+
if (value === undefined || value === null || String(value) === String(object?.[parent.attribute] ?? "")) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
await checkModelParent(model, value, context);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Enforce a model's permission for an action on an object: the single check used by every client path (REST, gRPC,
|
|
217
|
+
* MCP, GraphQL and any transport dispatching operations)
|
|
218
|
+
*
|
|
219
|
+
* A caller who may not read the object (`canAct(ctx, "get", object)` refused) gets exactly the error of a missing
|
|
220
|
+
* object (`NotFound("Object not found")`), whatever the action, so a refusal never reveals that the key exists. A
|
|
221
|
+
* caller who may read the object but not perform the action gets a `Forbidden`. On `"create"` the object does not
|
|
222
|
+
* exist yet: a refusal is always a `Forbidden`.
|
|
223
|
+
*
|
|
224
|
+
* The refusal reason returned by `canAct` is logged, never sent to the client.
|
|
225
|
+
*
|
|
226
|
+
* @param object - the model instance
|
|
227
|
+
* @param context - the caller context
|
|
228
|
+
* @param action - the action name
|
|
229
|
+
* @param model - the model class (defaults to the object's class)
|
|
230
|
+
* @throws WebdaError.NotFound when the caller may not read the object
|
|
231
|
+
* @throws WebdaError.Forbidden when the caller may read the object but not perform the action
|
|
232
|
+
*/
|
|
233
|
+
export async function checkModelPermission(object, context, action, model) {
|
|
234
|
+
const check = staticCanAct(model, object);
|
|
235
|
+
const allowed = await askPermission(check, context, action, object);
|
|
236
|
+
if (allowed === true) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
useLog("DEBUG", `Permission refused for '${action}' on ${object?.constructor?.name ?? "object"}`, typeof allowed === "string" ? allowed : "");
|
|
240
|
+
if (action !== "create" && (action === "get" || (await askPermission(check, context, "get", object)) !== true)) {
|
|
241
|
+
throw new WebdaError.NotFound(NOT_FOUND_MESSAGE);
|
|
242
|
+
}
|
|
243
|
+
throw new WebdaError.Forbidden(`Action ${action} not allowed`);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Enforce a model's permission for a static (class-level) action: `canAct(context, action)` without object
|
|
247
|
+
*
|
|
248
|
+
* There is no object to hide, so a refusal is always a `Forbidden`.
|
|
249
|
+
* @param model - the model class
|
|
250
|
+
* @param context - the caller context
|
|
251
|
+
* @param action - the action name
|
|
252
|
+
* @throws WebdaError.Forbidden when refused
|
|
253
|
+
*/
|
|
254
|
+
export async function checkStaticModelPermission(model, context, action) {
|
|
255
|
+
const allowed = await askPermission(staticCanAct(model), context, action, undefined);
|
|
256
|
+
if (allowed === true) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
useLog("DEBUG", `Permission refused for static '${action}' on ${model?.name ?? "model"}`, typeof allowed === "string" ? allowed : "");
|
|
260
|
+
throw new WebdaError.Forbidden(`Action ${action} not allowed`);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Persist a new object with the repository `create`, which refuses an existing key (atomically in every bundled
|
|
264
|
+
* repository), instead of `save()`, which upserts
|
|
265
|
+
* @param object - the new model instance
|
|
266
|
+
* @returns the object
|
|
267
|
+
* @throws WebdaError.Conflict when an object with the same primary key exists
|
|
268
|
+
*/
|
|
269
|
+
export async function createModel(object) {
|
|
270
|
+
try {
|
|
271
|
+
await object.getRepository().create(object);
|
|
272
|
+
}
|
|
273
|
+
catch (err) {
|
|
274
|
+
if (/^Already exists/.test(`${err?.message}`)) {
|
|
275
|
+
throw new WebdaError.Conflict("Object already exists");
|
|
276
|
+
}
|
|
277
|
+
throw err;
|
|
278
|
+
}
|
|
279
|
+
return object;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* AND the model's permission query into a client query
|
|
283
|
+
*
|
|
284
|
+
* Both sides are parsed and combined on the expression tree, so a client `OR` keeps its precedence. The client
|
|
285
|
+
* ORDER BY, LIMIT and OFFSET are kept.
|
|
286
|
+
*
|
|
287
|
+
* @param query - the client query
|
|
288
|
+
* @param permission - the permission query, if any
|
|
289
|
+
* @returns the query to run
|
|
290
|
+
* @throws SyntaxError if the client query is invalid
|
|
291
|
+
*/
|
|
292
|
+
export function mergePermissionQuery(query, permission) {
|
|
293
|
+
if (!permission?.query) {
|
|
294
|
+
return query;
|
|
295
|
+
}
|
|
296
|
+
return new QueryValidator(query ?? "").merge(permission.query, "AND").toString();
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Highest LIMIT a client query can ask for: larger LIMITs are lowered to it
|
|
300
|
+
*/
|
|
301
|
+
export const MAX_QUERY_LIMIT = 1000;
|
|
302
|
+
/**
|
|
303
|
+
* Rows a permission-filtered query scans to fill one page: ten times the page LIMIT, at least
|
|
304
|
+
* {@link MIN_SCANNED_ROWS}, at most {@link MAX_SCANNED_ROWS}
|
|
305
|
+
*/
|
|
306
|
+
export const SCAN_FACTOR = 10;
|
|
307
|
+
/**
|
|
308
|
+
* Lower bound of the scan budget of a permission-filtered page
|
|
309
|
+
*/
|
|
310
|
+
export const MIN_SCANNED_ROWS = 100;
|
|
311
|
+
/**
|
|
312
|
+
* Absolute bound of the scan budget of a permission-filtered page
|
|
313
|
+
*/
|
|
314
|
+
export const MAX_SCANNED_ROWS = 10000;
|
|
315
|
+
/**
|
|
316
|
+
* Most store pages read to fill one page, whatever their size
|
|
317
|
+
*/
|
|
318
|
+
export const MAX_REFILL_PAGES = 100;
|
|
319
|
+
/**
|
|
320
|
+
* Lifetime of a continuation token (one hour): paging has to resume within it
|
|
321
|
+
*/
|
|
322
|
+
export const CONTINUATION_TOKEN_TTL_MS = 60 * 60 * 1000;
|
|
323
|
+
/**
|
|
324
|
+
* Refuse a client query that reads private (`__`-prefixed) fields, at any depth, in its filter or ORDER BY: a filter
|
|
325
|
+
* on a private field (a password hash...) would reveal its value through which rows match
|
|
326
|
+
* @param query - the parsed client query
|
|
327
|
+
* @throws WebdaError.BadRequest when a field path has a `__`-prefixed segment
|
|
328
|
+
*/
|
|
329
|
+
export function assertNoPrivateFields(query) {
|
|
330
|
+
const isPrivate = (path) => path.some(segment => segment.startsWith("__"));
|
|
331
|
+
const visit = (expression) => {
|
|
332
|
+
if (expression instanceof LogicalExpression) {
|
|
333
|
+
expression.children.forEach(visit);
|
|
334
|
+
}
|
|
335
|
+
else if (expression instanceof ComparisonExpression && isPrivate(expression.attribute)) {
|
|
336
|
+
throw new WebdaError.BadRequest("Private fields cannot be queried");
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
visit(query.getExpression());
|
|
340
|
+
if ((query.getQuery().orderBy ?? []).some(o => isPrivate(o.field.split(".")))) {
|
|
341
|
+
throw new WebdaError.BadRequest("Private fields cannot be queried");
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Type tag of a sealed continuation token, so no other ciphertext of the application can be sent as one
|
|
346
|
+
*/
|
|
347
|
+
const TOKEN_TYPE = "webda-query-token";
|
|
348
|
+
/**
|
|
349
|
+
* @param binding - the token binding
|
|
350
|
+
* @returns the short hash of the query
|
|
351
|
+
*/
|
|
352
|
+
function queryHash(binding) {
|
|
353
|
+
return createHash("sha256").update(binding.query).digest("base64url").substring(0, 32);
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Seal a store continuation token: encrypted with the CryptoService (random IV, padded to 64 bytes) so its value
|
|
357
|
+
* cannot be read, compared or forged by the client; bound to the model, the query and the caller; and expiring
|
|
358
|
+
* after `ttl` ({@link CONTINUATION_TOKEN_TTL_MS})
|
|
359
|
+
* @param token - the store token
|
|
360
|
+
* @param binding - what the token is bound to
|
|
361
|
+
* @param ttl - lifetime in milliseconds
|
|
362
|
+
* @returns the opaque token
|
|
363
|
+
*/
|
|
364
|
+
export async function sealContinuationToken(token, binding, ttl = CONTINUATION_TOKEN_TTL_MS) {
|
|
365
|
+
const payload = {
|
|
366
|
+
typ: TOKEN_TYPE,
|
|
367
|
+
t: token,
|
|
368
|
+
m: binding.model,
|
|
369
|
+
q: queryHash(binding),
|
|
370
|
+
u: binding.user,
|
|
371
|
+
exp: Date.now() + ttl,
|
|
372
|
+
p: ""
|
|
373
|
+
};
|
|
374
|
+
const base = JSON.stringify(payload).length;
|
|
375
|
+
return useCrypto().encrypt({ ...payload, p: "=".repeat((64 - (base % 64)) % 64) });
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Open a token produced by {@link sealContinuationToken}
|
|
379
|
+
* @param token - the opaque token
|
|
380
|
+
* @param binding - what the token must be bound to
|
|
381
|
+
* @returns the store token
|
|
382
|
+
* @throws WebdaError.BadRequest when the token was not produced by this application for this model, query and
|
|
383
|
+
* caller, or has expired
|
|
384
|
+
*/
|
|
385
|
+
export async function unsealContinuationToken(token, binding) {
|
|
386
|
+
let data;
|
|
387
|
+
try {
|
|
388
|
+
data = await useCrypto().decrypt(token);
|
|
389
|
+
}
|
|
390
|
+
catch {
|
|
391
|
+
// Invalid, forged or expired key
|
|
392
|
+
}
|
|
393
|
+
if (data?.typ === TOKEN_TYPE &&
|
|
394
|
+
typeof data.t === "string" &&
|
|
395
|
+
data.m === binding.model &&
|
|
396
|
+
data.q === queryHash(binding) &&
|
|
397
|
+
data.u === binding.user &&
|
|
398
|
+
typeof data.exp === "number" &&
|
|
399
|
+
data.exp > Date.now()) {
|
|
400
|
+
return data.t;
|
|
401
|
+
}
|
|
402
|
+
throw new WebdaError.BadRequest("Invalid continuation token");
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* @param model - the model class
|
|
406
|
+
* @returns its identifier, or its class name for classes registered without metadata
|
|
407
|
+
*/
|
|
408
|
+
function modelIdentifier(model) {
|
|
409
|
+
try {
|
|
410
|
+
return useModelMetadata(model)?.Identifier ?? model?.name ?? "model";
|
|
411
|
+
}
|
|
412
|
+
catch {
|
|
413
|
+
return model?.name ?? "model";
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Query a model as the caller
|
|
418
|
+
*
|
|
419
|
+
* - the client query may not read private (`__`) fields (400), and its LIMIT is lowered to {@link MAX_QUERY_LIMIT};
|
|
420
|
+
* - a model defining neither `canAct` form refuses every row: the store is not asked;
|
|
421
|
+
* - the model's static `getPermissionQuery(context)` is ANDed into the query;
|
|
422
|
+
* - every result is checked with the static `canAct(context, "get", row)` and refused ones are dropped. Refused rows
|
|
423
|
+
* are replaced by continuing the scan (next store pages, asking only for the missing rows), within a budget of
|
|
424
|
+
* `SCAN_FACTOR` x LIMIT rows (between `MIN_SCANNED_ROWS` and `MAX_SCANNED_ROWS`) and {@link MAX_REFILL_PAGES}
|
|
425
|
+
* store pages. When the budget is spent, an empty page carries no token;
|
|
426
|
+
* - the continuation token is sealed ({@link sealContinuationToken}): a store token counting or naming rows
|
|
427
|
+
* (Postgres/Firestore offsets, Dynamo keys, memory offsets) would otherwise reveal hidden matches. It is bound to
|
|
428
|
+
* the model, the query and the caller, expires after {@link CONTINUATION_TOKEN_TTL_MS}, and is sent back as is in
|
|
429
|
+
* `OFFSET`; any other value is a 400.
|
|
430
|
+
*
|
|
431
|
+
* @param model - the model class
|
|
432
|
+
* @param query - the client query
|
|
433
|
+
* @param context - the caller context
|
|
434
|
+
* @returns the query results the caller may read
|
|
435
|
+
*/
|
|
436
|
+
export async function queryModelWithPermissions(model, query, context) {
|
|
437
|
+
const client = new QueryValidator(query ?? "");
|
|
438
|
+
assertNoPrivateFields(client);
|
|
439
|
+
if (!hasModelPermissionCheck(model)) {
|
|
440
|
+
// Deny by default: no row can be read, the store is not even asked
|
|
441
|
+
return { results: [], continuationToken: undefined };
|
|
442
|
+
}
|
|
443
|
+
const limit = Math.min(client.getLimit(), MAX_QUERY_LIMIT);
|
|
444
|
+
const permission = typeof model.getPermissionQuery === "function" ? model.getPermissionQuery(context) : undefined;
|
|
445
|
+
const merged = new QueryValidator(mergePermissionQuery(query ?? "", permission));
|
|
446
|
+
// The query without its LIMIT and OFFSET: filter and ORDER BY
|
|
447
|
+
const orderBy = (merged.getQuery().orderBy ?? []).map(o => `${o.field} ${o.direction}`).join(", ");
|
|
448
|
+
const base = `${merged.getExpression().toString()}${orderBy ? ` ORDER BY ${orderBy}` : ""}`.trim();
|
|
449
|
+
const binding = {
|
|
450
|
+
model: modelIdentifier(model),
|
|
451
|
+
query: base,
|
|
452
|
+
user: context.getCurrentUserId() || "anonymous"
|
|
453
|
+
};
|
|
454
|
+
let offset = client.getOffset();
|
|
455
|
+
if (offset) {
|
|
456
|
+
offset = await unsealContinuationToken(offset, binding);
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* @param count - the LIMIT
|
|
460
|
+
* @param token - the store OFFSET
|
|
461
|
+
* @returns the query to send to the store
|
|
462
|
+
*/
|
|
463
|
+
const page = (count, token) => new QueryValidator(base).merge(`LIMIT ${count}${token ? ` OFFSET ${JSON.stringify(token)}` : ""}`).toString();
|
|
464
|
+
const budget = Math.min(Math.max(limit * SCAN_FACTOR, MIN_SCANNED_ROWS), MAX_SCANNED_ROWS);
|
|
465
|
+
const results = [];
|
|
466
|
+
let scanned = 0;
|
|
467
|
+
let pages = 1;
|
|
468
|
+
let res = await model.query(page(limit, offset));
|
|
469
|
+
let token;
|
|
470
|
+
while (true) {
|
|
471
|
+
const rows = res.results ?? [];
|
|
472
|
+
scanned += rows.length;
|
|
473
|
+
// Each row is checked with the queried class and, for a subclass row, its own class too
|
|
474
|
+
const readable = await Promise.all(rows.map(async (r) => (await askPermission(staticCanAct(model, r), context, "get", r)) === true));
|
|
475
|
+
results.push(...rows.filter((_r, i) => readable[i]));
|
|
476
|
+
token = res.continuationToken;
|
|
477
|
+
if (!token || results.length >= limit) {
|
|
478
|
+
// Store exhausted, or page full
|
|
479
|
+
break;
|
|
480
|
+
}
|
|
481
|
+
if (scanned >= budget || pages >= MAX_REFILL_PAGES || rows.length === 0) {
|
|
482
|
+
// Budget spent, or a store that does not progress: a token on an empty page would only reveal hidden matches
|
|
483
|
+
token = results.length ? token : undefined;
|
|
484
|
+
break;
|
|
485
|
+
}
|
|
486
|
+
// Refill: continue after the last scanned row, asking only for the rows still missing
|
|
487
|
+
pages++;
|
|
488
|
+
res = await model.query(page(Math.min(limit - results.length, budget - scanned), token));
|
|
489
|
+
}
|
|
490
|
+
return {
|
|
491
|
+
results,
|
|
492
|
+
continuationToken: token ? await sealContinuationToken(String(token), binding) : undefined
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
//# sourceMappingURL=permissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.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,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACrD,KAAK,GAAG,GAAG,CAAC,iBAAiB,CAAC;QAC9B,IAAI,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,IAAI,KAAK,EAAE,CAAC;YACtC,gCAAgC;YAChC,MAAM;QACR,CAAC;QACD,IAAI,OAAO,IAAI,MAAM,IAAI,KAAK,IAAI,gBAAgB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxE,6GAA6G;YAC7G,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;YAC3C,MAAM;QACR,CAAC;QACD,sFAAsF;QACtF,KAAK,EAAE,CAAC;QACR,GAAG,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IAC3F,CAAC;IACD,OAAO;QACL,OAAO;QACP,iBAAiB,EAAE,KAAK,CAAC,CAAC,CAAC,MAAM,qBAAqB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS;KAC3F,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rolemodel.model.d.ts","sourceRoot":"","sources":["../../src/models/rolemodel.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"rolemodel.model.d.ts","sourceRoot":"","sources":["../../src/models/rolemodel.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAGjE,8EAA8E;AAC9E,uBAAe,SAAU,SAAQ,KAAK;IACpC,QAAQ,CAAC,WAAW,IAAI;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAElD;;;OAGG;IACH,YAAY,IAAI,OAAO,CAEtB;IAED;;;;OAIG;IACG,QAAQ,CAAC,GAAG,EAAE,iBAAiB,gBAYpC;IAED;;;;;OAKG;IACG,MAAM,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,CAalF;CACF;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Model } from "@webda/models";
|
|
2
2
|
import * as WebdaError from "../errors/errors.js";
|
|
3
|
-
import { useContext } from "../contexts/execution.js";
|
|
4
3
|
/** Model with role-based access control, mapping actions to required roles */
|
|
5
4
|
class RoleModel extends Model {
|
|
6
5
|
/**
|
|
@@ -42,7 +41,7 @@ class RoleModel extends Model {
|
|
|
42
41
|
}
|
|
43
42
|
return "No permission for this action defined";
|
|
44
43
|
}
|
|
45
|
-
const roles = await this.getRoles(
|
|
44
|
+
const roles = await this.getRoles(context);
|
|
46
45
|
if (roles.indexOf(this.getRolesMap()[action]) >= 0) {
|
|
47
46
|
return true;
|
|
48
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rolemodel.model.js","sourceRoot":"","sources":["../../src/models/rolemodel.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"rolemodel.model.js","sourceRoot":"","sources":["../../src/models/rolemodel.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC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E,SAAS,EAAE,CAAC"}
|
|
@@ -86,6 +86,18 @@ export declare class User extends UuidModel {
|
|
|
86
86
|
* @returns the result string
|
|
87
87
|
*/
|
|
88
88
|
getDisplayName(): string;
|
|
89
|
+
/**
|
|
90
|
+
* Store filter matching {@link User.canAct}: a caller only finds its own user, so users cannot be enumerated
|
|
91
|
+
*
|
|
92
|
+
* Subclasses inherit this filter even when they override `canAct` (it fails closed: it can only hide rows). A
|
|
93
|
+
* subclass whose `canAct` is more permissive overrides this method (returning `null` disables the store filter).
|
|
94
|
+
* @param context - the caller context
|
|
95
|
+
* @returns the permission query
|
|
96
|
+
*/
|
|
97
|
+
static getPermissionQuery(context?: IOperationContext): null | {
|
|
98
|
+
partial: boolean;
|
|
99
|
+
query: string;
|
|
100
|
+
};
|
|
89
101
|
/**
|
|
90
102
|
* Only the user themselves can act on their own object
|
|
91
103
|
* @param ctx - the operation context
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.model.d.ts","sourceRoot":"","sources":["../../src/models/user.model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"user.model.d.ts","sourceRoot":"","sources":["../../src/models/user.model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAsB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE1G,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG;IAC3C,KAAK,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC;IACnB,MAAM,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC;CACrB,CAAC;AACF;;;;G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MAAM,GAAG,OAAO,CAAC,CAK9E;IAED;;;OAGG;IACH,QAAQ,WAEP;IACD,SAAS,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,GAAG,GAAG,IAAI,CAiBhD;CACF"}
|
package/lib/models/user.model.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { WEBDA_STORAGE } from "@webda/models";
|
|
2
|
+
import { bind } from "@webda/ql";
|
|
2
3
|
import { Password, V3_PASSWORD_MAPPED } from "./password.model.js";
|
|
3
4
|
import { UuidModel, WEBDA_EVENTS } from "@webda/models";
|
|
4
5
|
/**
|
|
@@ -123,6 +124,21 @@ export class User extends UuidModel {
|
|
|
123
124
|
getDisplayName() {
|
|
124
125
|
return this.displayName;
|
|
125
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Store filter matching {@link User.canAct}: a caller only finds its own user, so users cannot be enumerated
|
|
129
|
+
*
|
|
130
|
+
* Subclasses inherit this filter even when they override `canAct` (it fails closed: it can only hide rows). A
|
|
131
|
+
* subclass whose `canAct` is more permissive overrides this method (returning `null` disables the store filter).
|
|
132
|
+
* @param context - the caller context
|
|
133
|
+
* @returns the permission query
|
|
134
|
+
*/
|
|
135
|
+
static getPermissionQuery(context) {
|
|
136
|
+
if (!context) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
const userId = context.getCurrentUserId();
|
|
140
|
+
return { query: userId ? bind("uuid = ?", [userId]) : "FALSE", partial: false };
|
|
141
|
+
}
|
|
126
142
|
/**
|
|
127
143
|
* Only the user themselves can act on their own object
|
|
128
144
|
* @param ctx - the operation context
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.model.js","sourceRoot":"","sources":["../../src/models/user.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAoD,SAAS,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{"version":3,"file":"restoperationstransport.service.d.ts","sourceRoot":"","sources":["../../src/rest/restoperationstransport.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACxG,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAQvD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,4BAA4B,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA6CnF;;GAEG;AACH,qBAAa,iCAAkC,SAAQ,6BAA6B;IAClF;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;;;OAQG;IACH,cAAc,EAAE,MAAM,CAAY;IAClC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAO;IAClB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,iBAAiB,CAAC;IACpC;;;;OAIG;IACH,WAAW,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IAE5B;;;;OAIG;IACH,IAAI,CAAC,MAAM,GAAE,GAAQ,GAAG,IAAI,CAS3B;CACF;AAED;;;;;;;;GAQG;AACH,qBAAa,uBAAuB,CAClC,CAAC,SAAS,iCAAiC,GAAG,iCAAiC,CAC/E,SAAQ,mBAAmB,CAAC,CAAC,CAAC;IAC9B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"restoperationstransport.service.d.ts","sourceRoot":"","sources":["../../src/rest/restoperationstransport.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,6BAA6B,E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