@antelopejs/interface-dms 0.14.7-next.1004.gbb93de3 → 0.14.7-next.1005.ga44543e
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.
|
@@ -28,8 +28,15 @@ export declare const VIEW_ARCHIVED_ACTION = "viewArchived";
|
|
|
28
28
|
* real table view declares.
|
|
29
29
|
*/
|
|
30
30
|
export declare const GATE_BYPASSABLE_ACTIONS: string[];
|
|
31
|
-
/**
|
|
32
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The caller's effective permission set, once the tenant access gate admits
|
|
33
|
+
* them and they hold a permission `actionId` carries on a mounted table view.
|
|
34
|
+
* An action no mounted table view declares is served to a holder of `*`
|
|
35
|
+
* alone. Throws a 403 otherwise.
|
|
36
|
+
*
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export declare function authorizeAction(thisObj: DataControllerInstance, actionId: string, user: User, tenantId: string): Promise<Set<string>>;
|
|
33
40
|
/**
|
|
34
41
|
* `baseRoute` behind the permission check of `actionId`: the route takes the
|
|
35
42
|
* user after the arguments of `baseRoute`, and runs `baseRoute` only once the
|
|
@@ -48,7 +48,14 @@ exports.GATE_BYPASSABLE_ACTIONS = [
|
|
|
48
48
|
function isGateBypassableAction(actionId, permissionIds) {
|
|
49
49
|
return permissionIds.length > 0 && exports.GATE_BYPASSABLE_ACTIONS.includes(actionId);
|
|
50
50
|
}
|
|
51
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* The caller's effective permission set, once the tenant access gate admits
|
|
53
|
+
* them and they hold a permission `actionId` carries on a mounted table view.
|
|
54
|
+
* An action no mounted table view declares is served to a holder of `*`
|
|
55
|
+
* alone. Throws a 403 otherwise.
|
|
56
|
+
*
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
52
59
|
async function authorizeAction(thisObj, actionId, user, tenantId) {
|
|
53
60
|
const meta = (0, meta_1.getTableViewMetaFor)(thisObj);
|
|
54
61
|
const permissionIds = meta.actionPermissionIds(actionId);
|
|
@@ -59,18 +66,17 @@ async function authorizeAction(thisObj, actionId, user, tenantId) {
|
|
|
59
66
|
}
|
|
60
67
|
await (0, tenant_access_1.AssertTenantAccess)(user._id, tenantId);
|
|
61
68
|
}
|
|
62
|
-
if (permissionIds.length === 0) {
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
69
|
const roleModel = (0, interface_database_decorators_1.GetModel)(db_1.RoleModel, tenantId);
|
|
66
70
|
const memberModel = (0, interface_database_decorators_1.GetModel)(db_1.TenantMemberModel, tenantId);
|
|
67
71
|
const member = await memberModel.getByUser(user._id);
|
|
68
72
|
const roleIds = member?.roleIds ?? [];
|
|
69
73
|
const permissions = await (0, permissions_1.GetEffectiveUserPermissions)(user, tenantId, roleIds, roleModel);
|
|
70
|
-
if (
|
|
74
|
+
if (permissionIds.length === 0) {
|
|
75
|
+
(0, interface_api_util_1.assert)(permissions.has("*"), 403, `Forbidden: action "${actionId}" declares no permission`);
|
|
71
76
|
return permissions;
|
|
72
77
|
}
|
|
73
|
-
(0, interface_api_util_1.assert)(
|
|
78
|
+
(0, interface_api_util_1.assert)(await (0, permissions_1.HasAnyPermission)(permissions, permissionIds), 403, `Forbidden: missing permission ${permissionIds.join(" or ")}`);
|
|
79
|
+
return permissions;
|
|
74
80
|
}
|
|
75
81
|
/**
|
|
76
82
|
* `baseRoute` behind the permission check of `actionId`: the route takes the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../src/base/table-view/internal/auth.ts"],"names":[],"mappings":";;;;;;;AACA,uEAA2E;AAC3E,gEAA6D;AAM7D,6FAAqE;AACrE,oCAA2D;AAC3D,sDAG8B;AAC9B,4DAA6D;AAC7D,0DAA4D;AAC5D,wCAAyC;AAEzC,iCAA6C;AAE7C;;;;;;;GAOG;AACU,QAAA,WAAW,GAAG,MAAM,CAAC;AAClC,gBAAgB;AACH,QAAA,WAAW,GAAG,MAAM,CA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IAE/D,OAAO;QACL,MAAM,EAAE,SAAS,CAAC,MAAM;QACxB,IAAI,EAAE,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,IAAA,eAAQ,GAAE,CAAC;QACrC,IAAI,EAAE,KAAK,WAET,GAAmB,EACnB,MAAS,EACT,IAAO,EACP,IAAU;YAEV,MAAM,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAA,mCAAkB,EAAC,GAAG,CAAC,CAAC,CAAC;YACrE,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QACtD,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,+BACE,QAAgB,EAChB,SAA4D;IAE5D,OAAO;QACL,MAAM,EAAE,SAAS,CAAC,MAAM;QACxB,IAAI,EAAE,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,IAAA,eAAQ,GAAE,CAAC;QACrC,IAAI,EAAE,KAAK,WAET,GAAmB,EACnB,MAAS,EACT,IAAU;YAEV,MAAM,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAA,mCAAkB,EAAC,GAAG,CAAC,CAAC,CAAC;YACrE,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QAChD,CAAC;KACF,CAAC;AACJ,CAAC;AAED,gBAAgB;AAChB,gCACE,QAAgB,EAChB,SAA0E;IAE1E,OAAO;QACL,QAAQ,EAAE,SAAS,CAAC,QAAQ;QAC5B,OAAO,EAAE,SAAS,CAAC,OAAO;QAC1B,QAAQ,EAAE,eAAe,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC;KACxD,CAAC;AACJ,CAAC"}
|
|
@@ -68,7 +68,7 @@ Permissions are applied on top. The table view registers `list` and `select` as
|
|
|
68
68
|
|
|
69
69
|
Several pages may each mount their own `TableView` over one data controller, and they all share its data routes. A read action (`list`, `select`, `view`, `export`, `viewArchived`) accepts the permission from any table view a page mounts on that controller; a write action (`add`, `edit`, `delete`, `archive`, `restore`) accepts only the writing table view's, so a user granted `add` on a read-only table view cannot create rows. A read-only table view still declares the write actions the controller offers: while no table view writes through the controller, they keep its write routes behind permission ids nobody is granted by default. The inline add button of a relation field pointing at the controller follows the same rule (`addPermissionIds`).
|
|
70
70
|
|
|
71
|
-
A `new` or `edit` `ResourceForm` block over the controller submits to the same routes, so the native files staged from its fields are accepted on save as well, alongside those of the writing table view. It adds no permission of its own to the union: the routes still require the action's permission from a table view of the controller when
|
|
71
|
+
A `new` or `edit` `ResourceForm` block over the controller submits to the same routes, so the native files staged from its fields are accepted on save as well, alongside those of the writing table view. It adds no permission of its own to the union: the routes still require the action's permission from a mounted table view of the controller, and refuse everyone but a platform owner when none declares it, exactly as for the block's other fields. The `new` and `edit` forms a page-mode table view mounts on its form sub-pages count the same way: each is a component of its own sub-page, so the files staged from it are accepted on save, under the same table view permissions.
|
|
72
72
|
|
|
73
73
|
`TableViewRowActionOptionsSerialized` is the transported shape: rules and flags untyped, `custom` as `CustomRowActionSerialized[]`, plus a `showArchived?: boolean` field the builder fills from the `viewArchived` permission.
|
|
74
74
|
|
|
@@ -21,7 +21,7 @@ A read-only table view with no data controller (`tableViewFromSource`). `TableVi
|
|
|
21
21
|
Data routes are registered against the controller, not against a page, so the opt-out is controller-level and **latched**: once any `TableView()` call on a controller declares it, the controller's routes bypass the gate wherever they are rendered. A later registration of the same controller without the flag cannot re-gate them, and gets a warning saying so. Two consequences worth designing around:
|
|
22
22
|
|
|
23
23
|
- Declaring the flag on a controller opens its routes for every table view built on it, including one mounted on an ordinary page.
|
|
24
|
-
-
|
|
24
|
+
- An action that carries no permission id, such as a plain list on a component that was never mounted, stays behind the gate, and in an admitted tenant answers 403 to everyone but a platform owner. Keep every action a flagged controller serves stamped with a permission.
|
|
25
25
|
|
|
26
26
|
## Write to an external connection
|
|
27
27
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/interface-dms",
|
|
3
|
-
"version": "0.14.7-next.
|
|
3
|
+
"version": "0.14.7-next.1005.ga44543e",
|
|
4
4
|
"description": "Public AntelopeJS interfaces of the DMS: pages, components, permissions, tenancy, auth, notifications and HTML rendering.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"provenance": true,
|
|
133
133
|
"registry": "https://registry.npmjs.org/"
|
|
134
134
|
},
|
|
135
|
-
"gitHead": "
|
|
135
|
+
"gitHead": "a44543eaecdf4feb0a6162543e1de098b2d1c137",
|
|
136
136
|
"scripts": {
|
|
137
137
|
"build": "rimraf dist && antelopejs-tsc",
|
|
138
138
|
"typecheck": "antelopejs-tsc --noEmit",
|