@live-change/access-control-service 0.8.49 → 0.8.50
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/access.js +4 -1
- package/model.js +6 -0
- package/package.json +3 -3
- package/view.js +55 -4
package/access.js
CHANGED
|
@@ -54,7 +54,8 @@ export default (definition) => {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
async function getUnitClientRoles(client, { objectType, object }, ignorePublic) {
|
|
57
|
-
const [ sessionOrUserType, sessionOrUser ] =
|
|
57
|
+
const [ sessionOrUserType, sessionOrUser ] =
|
|
58
|
+
client.user ? ['user_User', client.user] : ['session_Session', client.session]
|
|
58
59
|
const [
|
|
59
60
|
publicAccessData,
|
|
60
61
|
sessionAccess,
|
|
@@ -291,6 +292,7 @@ export default (definition) => {
|
|
|
291
292
|
}]
|
|
292
293
|
}
|
|
293
294
|
|
|
295
|
+
/*
|
|
294
296
|
function accessLimitedGet(client, objects, requiredRoles, path) {
|
|
295
297
|
const roles = getClientObjectsRoles(client, objects)
|
|
296
298
|
for(const requiredRole of requiredRoles) {
|
|
@@ -302,6 +304,7 @@ export default (definition) => {
|
|
|
302
304
|
if(path[0] !== 'database') throw new Error("non database path "+ JSON.stringify(path))
|
|
303
305
|
const isObject = path[1] === 'queryObject' || path[1] === ''
|
|
304
306
|
}
|
|
307
|
+
*/
|
|
305
308
|
|
|
306
309
|
return {
|
|
307
310
|
testRoles,
|
package/model.js
CHANGED
|
@@ -26,6 +26,12 @@ const Access = definition.model({
|
|
|
26
26
|
resetAccess: (params, { client, context, visibilityTest }) =>
|
|
27
27
|
visibilityTest || access.clientHasAdminAccess(client, params)
|
|
28
28
|
},
|
|
29
|
+
indexes: {
|
|
30
|
+
byOwnerRoleAndObject: {
|
|
31
|
+
property: ['sessionOrUserType', 'sessionOrUser', 'roles', 'objectType', 'object'],
|
|
32
|
+
multi: true
|
|
33
|
+
}
|
|
34
|
+
},
|
|
29
35
|
properties: {
|
|
30
36
|
roles: rolesArrayType,
|
|
31
37
|
lastUpdate: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/access-control-service",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.50",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"url": "https://www.viamage.com/"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@live-change/framework": "^0.8.
|
|
24
|
+
"@live-change/framework": "^0.8.50"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "c967d5304bdac5150a6272c8d7cbe8974d7c25e6",
|
|
27
27
|
"type": "module"
|
|
28
28
|
}
|
package/view.js
CHANGED
|
@@ -5,6 +5,8 @@ const app = App.app()
|
|
|
5
5
|
import accessModule from './access.js'
|
|
6
6
|
const access = accessModule(definition)
|
|
7
7
|
|
|
8
|
+
import { Access } from './model.js'
|
|
9
|
+
|
|
8
10
|
definition.view({
|
|
9
11
|
name: "myAccessTo",
|
|
10
12
|
properties: {
|
|
@@ -32,12 +34,12 @@ definition.view({
|
|
|
32
34
|
returns: {
|
|
33
35
|
type: Array,
|
|
34
36
|
of: {
|
|
35
|
-
type:
|
|
37
|
+
type: Object
|
|
36
38
|
}
|
|
37
39
|
},
|
|
38
40
|
async daoPath({ objectType, object, objects }, { client, service }, method) {
|
|
39
41
|
const allObjects = ((objectType && object) ? [{ objectType, object }] : []).concat(objects || [])
|
|
40
|
-
if(allObjects.length
|
|
42
|
+
if(allObjects.length === 0) throw 'empty_objects_list'
|
|
41
43
|
return access.accessPath(client, allObjects)
|
|
42
44
|
}
|
|
43
45
|
})
|
|
@@ -61,13 +63,62 @@ definition.view({
|
|
|
61
63
|
}
|
|
62
64
|
},
|
|
63
65
|
returns: {
|
|
64
|
-
type:
|
|
66
|
+
type: Object,
|
|
65
67
|
of: {
|
|
66
68
|
type: String
|
|
67
69
|
}
|
|
68
70
|
},
|
|
69
71
|
async daoPath({ objects }, { client, service }, method) {
|
|
70
|
-
if(objects.length
|
|
72
|
+
if(objects.length === 0) throw 'empty_objects_list'
|
|
71
73
|
return access.accessesPath(client, objects)
|
|
72
74
|
}
|
|
73
75
|
})
|
|
76
|
+
|
|
77
|
+
definition.view({
|
|
78
|
+
name: 'myAccessesByObjectType',
|
|
79
|
+
properties: {
|
|
80
|
+
objectType: {
|
|
81
|
+
type: String
|
|
82
|
+
},
|
|
83
|
+
...App.rangeProperties
|
|
84
|
+
},
|
|
85
|
+
returns: {
|
|
86
|
+
type: Array,
|
|
87
|
+
of: {
|
|
88
|
+
type: Access
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
async daoPath(properties, { client, service }, method) {
|
|
92
|
+
const [ sessionOrUserType, sessionOrUser ] = client.user ? ['user_User', client.user] : ['session_Session', client.session]
|
|
93
|
+
const { objectType } = properties
|
|
94
|
+
return Access.rangePath([sessionOrUserType, sessionOrUser, objectType], App.extractRange(properties))
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
definition.view({
|
|
99
|
+
name: 'myAccessesByObjectTypeAndRole',
|
|
100
|
+
properties: {
|
|
101
|
+
objectType: {
|
|
102
|
+
type: String
|
|
103
|
+
},
|
|
104
|
+
role: {
|
|
105
|
+
type: String
|
|
106
|
+
},
|
|
107
|
+
...App.rangeProperties
|
|
108
|
+
},
|
|
109
|
+
returns: {
|
|
110
|
+
type: Array,
|
|
111
|
+
of: {
|
|
112
|
+
type: Access
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
async daoPath(properties, { client, service }, method) {
|
|
116
|
+
const [ sessionOrUserType, sessionOrUser ] =
|
|
117
|
+
client.user ? ['user_User', client.user] : ['session_Session', client.session]
|
|
118
|
+
const { objectType, role } = properties
|
|
119
|
+
const path = Access.indexRangePath('byOwnerRoleAndObject',
|
|
120
|
+
[sessionOrUserType, sessionOrUser, role, objectType], App.extractRange(properties))
|
|
121
|
+
console.log("PATH", path)
|
|
122
|
+
return path
|
|
123
|
+
}
|
|
124
|
+
})
|