@crombolo/core 0.44.0 → 0.45.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/package.json +2 -2
- package/src/permissions.ts +13 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.0",
|
|
4
4
|
"description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. Domain model, entity keys and shared contracts for crombolo. No I/O.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Crombolo",
|
|
@@ -28,6 +28,6 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@crombolo/common": "0.
|
|
31
|
+
"@crombolo/common": "0.45.0"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/permissions.ts
CHANGED
|
@@ -66,9 +66,18 @@ export const RemotePermissions = {
|
|
|
66
66
|
PushProtected: 'Crombolo.Remote.PushProtected',
|
|
67
67
|
/** Changing a remote's schema, views, styles or code: a whole-site push, or such a bundle (story 167). */
|
|
68
68
|
ApplyStructure: 'Crombolo.Remote.ApplyStructure',
|
|
69
|
+
/** Installing the code a bundle carries, or a bundle as a dependency, on a site (story 241). */
|
|
70
|
+
InstallCode: 'Crombolo.Remote.InstallCode',
|
|
69
71
|
} as const
|
|
70
72
|
export type RemoteVerb = (typeof RemotePermissions)[keyof typeof RemotePermissions]
|
|
71
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Permissions an administrator does not hold by being one (story 241): only a
|
|
76
|
+
* group that names them grants them, so installing code on a site is always a
|
|
77
|
+
* choice somebody made and the audit log recorded.
|
|
78
|
+
*/
|
|
79
|
+
export const EXPLICIT_PERMISSIONS: ReadonlySet<string> = new Set([RemotePermissions.InstallCode])
|
|
80
|
+
|
|
72
81
|
/**
|
|
73
82
|
* Media (story 088). Umbraco has no media verbs: a group with the Media section
|
|
74
83
|
* may change everything in it. These are group-wide, held in the groups'
|
|
@@ -257,15 +266,16 @@ export function propertyValuePermissions(
|
|
|
257
266
|
}
|
|
258
267
|
|
|
259
268
|
/**
|
|
260
|
-
* An administrator bypasses the permission tables
|
|
261
|
-
*
|
|
269
|
+
* An administrator bypasses the permission tables, matching Umbraco: membership
|
|
270
|
+
* of the admin group is the check, not an exhaustive grant list. The one
|
|
271
|
+
* exception is `EXPLICIT_PERMISSIONS`, held only where a group names them.
|
|
262
272
|
*/
|
|
263
273
|
export function hasPermission(
|
|
264
274
|
permissions: UserPermissions,
|
|
265
275
|
verb: string,
|
|
266
276
|
nodeKey?: string,
|
|
267
277
|
): boolean {
|
|
268
|
-
if (permissions.isAdmin) return true
|
|
278
|
+
if (permissions.isAdmin && !EXPLICIT_PERMISSIONS.has(verb)) return true
|
|
269
279
|
if (permissions.global.has(verb)) return true
|
|
270
280
|
if (!nodeKey) return false
|
|
271
281
|
return permissions.granular.get(nodeKey)?.has(verb) === true
|