kuzzle 2.27.0 → 2.27.2
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/README.md +12 -6
- package/lib/api/controllers/adminController.js +9 -9
- package/lib/api/controllers/bulkController.js +9 -9
- package/lib/api/controllers/collectionController.js +17 -17
- package/lib/api/controllers/documentController.js +51 -51
- package/lib/api/controllers/indexController.js +4 -4
- package/lib/api/controllers/memoryStorageController.js +11 -11
- package/lib/api/controllers/realtimeController.js +1 -1
- package/lib/api/controllers/securityController.js +67 -70
- package/lib/api/controllers/serverController.js +5 -5
- package/lib/api/documentExtractor.js +3 -3
- package/lib/api/funnel.js +43 -43
- package/lib/api/rateLimiter.js +1 -1
- package/lib/cluster/command.js +4 -4
- package/lib/cluster/idCardHandler.js +1 -1
- package/lib/cluster/node.js +55 -55
- package/lib/cluster/subscriber.js +33 -33
- package/lib/cluster/workers/IDCardRenewer.js +4 -4
- package/lib/config/index.js +24 -24
- package/lib/core/auth/passportWrapper.js +6 -6
- package/lib/core/cache/cacheEngine.js +20 -20
- package/lib/core/network/accessLogger.js +15 -15
- package/lib/core/network/entryPoint.js +12 -12
- package/lib/core/network/httpRouter/index.js +4 -4
- package/lib/core/network/httpRouter/routePart.js +2 -2
- package/lib/core/network/protocols/httpwsProtocol.js +60 -53
- package/lib/core/network/protocols/internalProtocol.js +2 -2
- package/lib/core/network/protocols/mqttProtocol.js +9 -9
- package/lib/core/network/protocols/protocol.js +3 -3
- package/lib/core/network/router.js +7 -7
- package/lib/core/plugin/plugin.js +23 -23
- package/lib/core/plugin/pluginManifest.js +1 -1
- package/lib/core/plugin/pluginsManager.js +62 -62
- package/lib/core/realtime/notifier.js +14 -14
- package/lib/core/security/README.md +223 -0
- package/lib/core/security/roleRepository.js +18 -18
- package/lib/core/security/securityLoader.js +7 -7
- package/lib/core/security/userRepository.js +16 -16
- package/lib/core/shared/README.md +3 -0
- package/lib/core/shared/abstractManifest.js +1 -1
- package/lib/core/shared/sdk/impersonatedSdk.js +1 -1
- package/lib/core/shared/store.js +11 -11
- package/lib/core/statistics/statistics.js +15 -15
- package/lib/core/storage/clientAdapter.js +61 -61
- package/lib/core/validation/baseType.js +1 -1
- package/lib/core/validation/types/date.js +1 -1
- package/lib/core/validation/types/enum.js +5 -5
- package/lib/core/validation/types/geoShape.js +13 -13
- package/lib/core/validation/types/numeric.js +2 -2
- package/lib/core/validation/types/string.js +2 -2
- package/lib/core/validation/validation.js +71 -71
- package/lib/kerror/codes/index.js +23 -23
- package/lib/kuzzle/dumpGenerator.js +17 -17
- package/lib/kuzzle/event/kuzzleEventEmitter.js +9 -9
- package/lib/kuzzle/event/pipeRunner.js +2 -2
- package/lib/kuzzle/internalIndexHandler.js +8 -8
- package/lib/kuzzle/log.js +2 -2
- package/lib/kuzzle/vault.js +4 -4
- package/lib/model/security/role.js +3 -1
- package/lib/model/security/user.js +3 -1
- package/lib/model/storage/apiKey.js +3 -3
- package/lib/model/storage/baseModel.js +7 -7
- package/lib/service/cache/redis.js +3 -3
- package/lib/service/storage/elasticsearch.js +53 -54
- package/lib/service/storage/esWrapper.js +3 -3
- package/lib/service/storage/queryTranslator.js +2 -2
- package/lib/util/assertType.js +1 -1
- package/lib/util/deprecate.js +3 -3
- package/lib/util/extractFields.js +2 -2
- package/lib/util/wildcard.js +1 -1
- package/package.json +68 -81
|
@@ -70,7 +70,7 @@ class NotifierController {
|
|
|
70
70
|
"core:realtime:document:dispatch",
|
|
71
71
|
(rooms, notification, opts) => {
|
|
72
72
|
return this._notifyDocument(rooms, notification, opts);
|
|
73
|
-
}
|
|
73
|
+
},
|
|
74
74
|
);
|
|
75
75
|
|
|
76
76
|
/**
|
|
@@ -84,7 +84,7 @@ class NotifierController {
|
|
|
84
84
|
"core:realtime:user:sendMessage",
|
|
85
85
|
(room, notification, opts) => {
|
|
86
86
|
return this._notifyUser(room, notification, opts);
|
|
87
|
-
}
|
|
87
|
+
},
|
|
88
88
|
);
|
|
89
89
|
|
|
90
90
|
/**
|
|
@@ -95,7 +95,7 @@ class NotifierController {
|
|
|
95
95
|
*/
|
|
96
96
|
global.kuzzle.onAsk(
|
|
97
97
|
"core:realtime:document:mNotify",
|
|
98
|
-
(request, action, docs) => this.notifyDocuments(request, action, docs)
|
|
98
|
+
(request, action, docs) => this.notifyDocuments(request, action, docs),
|
|
99
99
|
);
|
|
100
100
|
|
|
101
101
|
/**
|
|
@@ -106,7 +106,7 @@ class NotifierController {
|
|
|
106
106
|
*/
|
|
107
107
|
global.kuzzle.onAsk(
|
|
108
108
|
"core:realtime:document:notify",
|
|
109
|
-
(request, action, doc) => this.notifyDocuments(request, action, [doc])
|
|
109
|
+
(request, action, doc) => this.notifyDocuments(request, action, [doc]),
|
|
110
110
|
);
|
|
111
111
|
|
|
112
112
|
/**
|
|
@@ -114,7 +114,7 @@ class NotifierController {
|
|
|
114
114
|
* @param {string} connectionId
|
|
115
115
|
*/
|
|
116
116
|
global.kuzzle.onAsk("core:realtime:tokenExpired:notify", (connectionId) =>
|
|
117
|
-
this.notifyTokenExpired(connectionId)
|
|
117
|
+
this.notifyTokenExpired(connectionId),
|
|
118
118
|
);
|
|
119
119
|
|
|
120
120
|
/**
|
|
@@ -122,7 +122,7 @@ class NotifierController {
|
|
|
122
122
|
* @param {Request} request
|
|
123
123
|
*/
|
|
124
124
|
global.kuzzle.onAsk("core:realtime:publish", (request) =>
|
|
125
|
-
this.publish(request)
|
|
125
|
+
this.publish(request),
|
|
126
126
|
);
|
|
127
127
|
}
|
|
128
128
|
|
|
@@ -146,7 +146,7 @@ class NotifierController {
|
|
|
146
146
|
request,
|
|
147
147
|
scope,
|
|
148
148
|
action,
|
|
149
|
-
content
|
|
149
|
+
content,
|
|
150
150
|
);
|
|
151
151
|
|
|
152
152
|
global.kuzzle.emit("core:notify:document", {
|
|
@@ -194,7 +194,7 @@ class NotifierController {
|
|
|
194
194
|
"notify:server",
|
|
195
195
|
[KUZZLE_NOTIFICATION_CHANNEL], // Sending notification on Kuzzle notification channel
|
|
196
196
|
new ServerNotification("TokenExpired", "Authentication Token Expired"),
|
|
197
|
-
connectionId
|
|
197
|
+
connectionId,
|
|
198
198
|
);
|
|
199
199
|
|
|
200
200
|
await this.module.hotelClerk.removeConnection(connectionId);
|
|
@@ -259,7 +259,7 @@ class NotifierController {
|
|
|
259
259
|
request,
|
|
260
260
|
"out",
|
|
261
261
|
"replace",
|
|
262
|
-
document
|
|
262
|
+
document,
|
|
263
263
|
);
|
|
264
264
|
}
|
|
265
265
|
|
|
@@ -321,7 +321,7 @@ class NotifierController {
|
|
|
321
321
|
"core",
|
|
322
322
|
"fatal",
|
|
323
323
|
"assertion_failed",
|
|
324
|
-
`unknown notify action "${doc.action}"
|
|
324
|
+
`unknown notify action "${doc.action}"`,
|
|
325
325
|
);
|
|
326
326
|
}
|
|
327
327
|
});
|
|
@@ -334,7 +334,7 @@ class NotifierController {
|
|
|
334
334
|
"core:cache:internal:store",
|
|
335
335
|
cacheIds[index],
|
|
336
336
|
JSON.stringify(rooms),
|
|
337
|
-
{ ttl: this.ttl }
|
|
337
|
+
{ ttl: this.ttl },
|
|
338
338
|
);
|
|
339
339
|
}
|
|
340
340
|
|
|
@@ -369,7 +369,7 @@ class NotifierController {
|
|
|
369
369
|
request,
|
|
370
370
|
"out",
|
|
371
371
|
"update",
|
|
372
|
-
document
|
|
372
|
+
document,
|
|
373
373
|
);
|
|
374
374
|
}
|
|
375
375
|
|
|
@@ -419,7 +419,7 @@ class NotifierController {
|
|
|
419
419
|
channels: channels,
|
|
420
420
|
connectionId: connectionId,
|
|
421
421
|
notification: updated,
|
|
422
|
-
}
|
|
422
|
+
},
|
|
423
423
|
);
|
|
424
424
|
|
|
425
425
|
const action = updatedInfo.connectionId ? "notify" : "broadcast";
|
|
@@ -526,7 +526,7 @@ class NotifierController {
|
|
|
526
526
|
request.input.args.index,
|
|
527
527
|
request.input.args.collection,
|
|
528
528
|
source || request.input.body || {},
|
|
529
|
-
id || request.input.args._id
|
|
529
|
+
id || request.input.args._id,
|
|
530
530
|
);
|
|
531
531
|
}
|
|
532
532
|
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# Kuzzle repositories
|
|
2
|
+
|
|
3
|
+
The Repository classes allow to fetch and store some Kuzzle internal business object from/to the persistent layer.
|
|
4
|
+
|
|
5
|
+
An abstract Repository class is available to be overridden if needed depending on the business needs.
|
|
6
|
+
The class handles the persistence both to the Cache module and to the database (elastic search by default).
|
|
7
|
+
|
|
8
|
+
The **Repository** class exposes the following methods:
|
|
9
|
+
|
|
10
|
+
## Constructor
|
|
11
|
+
|
|
12
|
+
The constructor expects to be passed the kuzzle instance and an options array.
|
|
13
|
+
|
|
14
|
+
### options
|
|
15
|
+
|
|
16
|
+
- _string_ collection (mandatory)
|
|
17
|
+
|
|
18
|
+
The underlying collection to store the Business objects to.
|
|
19
|
+
|
|
20
|
+
- _integer | false_ ttl (optional)
|
|
21
|
+
|
|
22
|
+
The ttl to use for the cache module. If set to false, the objects get an unlimited lifetime.
|
|
23
|
+
|
|
24
|
+
- _function_ ObjectConstructor (mandatory)
|
|
25
|
+
|
|
26
|
+
The constructor function for the business objects. The load\* methods will return some new instances of this function.
|
|
27
|
+
|
|
28
|
+
- _function_ indexStorage (optional)
|
|
29
|
+
|
|
30
|
+
The read engine to use to retrieve the business objects to/from the database. Defaults to Kuzzle's internalStorage (elasticsearch).
|
|
31
|
+
|
|
32
|
+
- _function_ cache (optional)
|
|
33
|
+
|
|
34
|
+
The cache database to use to store and retrieve the business objects to/from the cache. Defaults to Kuzzle's internal cache.
|
|
35
|
+
|
|
36
|
+
## loadOneFromDatabase
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
Repository.prototype.loadOneFromDatabase = function (id) {...}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This method loads one object from the database given its id.
|
|
43
|
+
|
|
44
|
+
### parameters
|
|
45
|
+
|
|
46
|
+
- _string_ id
|
|
47
|
+
|
|
48
|
+
The id of the document to retrieve.
|
|
49
|
+
|
|
50
|
+
### returns
|
|
51
|
+
|
|
52
|
+
Returns a promise that resolves to the _ObjectConstructor_ instance if found or null if the id does not exist in the database.
|
|
53
|
+
|
|
54
|
+
## loadMultiFromDatabase
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
Repository.prototype.loadMultiFromDatabase = function (ids, hydrate) {...}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
This method tries to load the business objects from the database matching the given ids.
|
|
61
|
+
|
|
62
|
+
### returns
|
|
63
|
+
|
|
64
|
+
Returns a promise that resolves to an array containing the _ObjectConstructor_ instances or documents that could be retrieved from the database.
|
|
65
|
+
|
|
66
|
+
If no matching document could be found, an empty array is returned.
|
|
67
|
+
|
|
68
|
+
## search
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
Repository.prototype.search = function (filter, from, size) {...}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
This method tries to load documents matching the given ids from the indexStorage.
|
|
75
|
+
|
|
76
|
+
### parameters
|
|
77
|
+
|
|
78
|
+
- _object_ query
|
|
79
|
+
|
|
80
|
+
The query sent to the indexStorage in order to retrieve documents.
|
|
81
|
+
|
|
82
|
+
- _Integer_ from
|
|
83
|
+
|
|
84
|
+
Starting offset (default: 0).
|
|
85
|
+
|
|
86
|
+
- _Integer_ size
|
|
87
|
+
|
|
88
|
+
Number of hits to return (default: 20).
|
|
89
|
+
|
|
90
|
+
### returns
|
|
91
|
+
|
|
92
|
+
Returns a promise that resolves to an object that contains a list of documents from indexStorage.
|
|
93
|
+
|
|
94
|
+
## loadFromCache
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
Repository.prototype.loadFromCache = function (id, opts) {...}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
This method loads one object from the cache given its id.
|
|
101
|
+
|
|
102
|
+
### parameters
|
|
103
|
+
|
|
104
|
+
- _string_ id
|
|
105
|
+
|
|
106
|
+
The object id to load from the cache.
|
|
107
|
+
|
|
108
|
+
- _Object_ opts
|
|
109
|
+
|
|
110
|
+
An optional options object.
|
|
111
|
+
|
|
112
|
+
Currently, the only optional parameter that can be pass to the method is _key_.
|
|
113
|
+
If no key is given to the method, defaults to _collection_ + '/' + id.
|
|
114
|
+
|
|
115
|
+
### returns
|
|
116
|
+
|
|
117
|
+
Returns a promise that resolves to the _ObjectConstructor_ instance if a matching document could be found in the cache, or _null_ if no document could be found.
|
|
118
|
+
|
|
119
|
+
## persistToDB
|
|
120
|
+
|
|
121
|
+
```javascript
|
|
122
|
+
Repository.prototype.persistToDB = function (object) {...}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
This method persists the given _ObjectConstructor_ instance to the database.
|
|
126
|
+
|
|
127
|
+
### parameters
|
|
128
|
+
|
|
129
|
+
- _ObjectConstructor_ object
|
|
130
|
+
|
|
131
|
+
The business object to persist.
|
|
132
|
+
|
|
133
|
+
### returns
|
|
134
|
+
|
|
135
|
+
_(Promise)_
|
|
136
|
+
|
|
137
|
+
## persistToCache
|
|
138
|
+
|
|
139
|
+
```javascript
|
|
140
|
+
Repository.prototype.persistToCache = function (object, opts) {...}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
This method persists the given _ObjectConstructor_ instance to the cache.
|
|
144
|
+
|
|
145
|
+
### parameters
|
|
146
|
+
|
|
147
|
+
- _ObjectConstructor_ object
|
|
148
|
+
|
|
149
|
+
The business object to persist.
|
|
150
|
+
|
|
151
|
+
- _Object_ opts
|
|
152
|
+
|
|
153
|
+
An optional options object.
|
|
154
|
+
The supported options are:
|
|
155
|
+
|
|
156
|
+
> - key: The key used to store the object in the cache engine. Defaults to _collection_ + '/' + object.\_id
|
|
157
|
+
> - ttl: Defaults to the repository ttl. If set to false, the object will never expire.
|
|
158
|
+
|
|
159
|
+
### returns
|
|
160
|
+
|
|
161
|
+
_(Promise)_
|
|
162
|
+
|
|
163
|
+
## refreshCacheTTL
|
|
164
|
+
|
|
165
|
+
```javascript
|
|
166
|
+
Repository.prototype.refreshCacheTTL = function (object, opts) {...}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
This methods updates the object's TTL in the cache engine.
|
|
170
|
+
|
|
171
|
+
### parameters
|
|
172
|
+
|
|
173
|
+
- _ObjectConstructor_ object
|
|
174
|
+
|
|
175
|
+
The business object to update.
|
|
176
|
+
|
|
177
|
+
- _Object_ opts
|
|
178
|
+
|
|
179
|
+
An optional options object.
|
|
180
|
+
The supported options are:
|
|
181
|
+
|
|
182
|
+
> - key: The key used to store the object in the cache engine. Defaults to _collection_ + '/' + object.\_id
|
|
183
|
+
> - ttl: Defaults to the repository ttl. If set to false, the object will never expire.
|
|
184
|
+
|
|
185
|
+
### returns
|
|
186
|
+
|
|
187
|
+
_(Promise)_
|
|
188
|
+
|
|
189
|
+
## serializeToCache
|
|
190
|
+
|
|
191
|
+
```javascript
|
|
192
|
+
Repository.prototype.serializeToCache = function (object) {...}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
This method transforms the business object before being persisted to the cache. The default implementation just returns the object without any transformation and is meant to be overridden.
|
|
196
|
+
|
|
197
|
+
### parameters
|
|
198
|
+
|
|
199
|
+
- _ObjectConstructor_ object
|
|
200
|
+
|
|
201
|
+
The business object to persist.
|
|
202
|
+
|
|
203
|
+
### returns
|
|
204
|
+
|
|
205
|
+
_(Object)_
|
|
206
|
+
|
|
207
|
+
## serializeToDatabase
|
|
208
|
+
|
|
209
|
+
```javascript
|
|
210
|
+
Repository.prototype.serializeToDatabase = function (object) {...}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
This method transforms the business object before being persisted to the cache. The default implementation just returns the object without any transformation and is meant to be overridden.
|
|
214
|
+
|
|
215
|
+
### parameters
|
|
216
|
+
|
|
217
|
+
- _ObjectConstructor_ object
|
|
218
|
+
|
|
219
|
+
The business object to persist.
|
|
220
|
+
|
|
221
|
+
### returns
|
|
222
|
+
|
|
223
|
+
_(Object)_
|
|
@@ -64,7 +64,7 @@ class RoleRepository extends Repository {
|
|
|
64
64
|
* @throws If already exists or if the content is invalid
|
|
65
65
|
*/
|
|
66
66
|
global.kuzzle.onAsk("core:security:role:create", (id, content, opts) =>
|
|
67
|
-
this.create(id, content, opts)
|
|
67
|
+
this.create(id, content, opts),
|
|
68
68
|
);
|
|
69
69
|
|
|
70
70
|
/**
|
|
@@ -77,7 +77,7 @@ class RoleRepository extends Repository {
|
|
|
77
77
|
*/
|
|
78
78
|
global.kuzzle.onAsk(
|
|
79
79
|
"core:security:role:createOrReplace",
|
|
80
|
-
(id, content, opts) => this.createOrReplace(id, content, opts)
|
|
80
|
+
(id, content, opts) => this.createOrReplace(id, content, opts),
|
|
81
81
|
);
|
|
82
82
|
|
|
83
83
|
/**
|
|
@@ -88,7 +88,7 @@ class RoleRepository extends Repository {
|
|
|
88
88
|
* still in use
|
|
89
89
|
*/
|
|
90
90
|
global.kuzzle.onAsk("core:security:role:delete", (id, opts) =>
|
|
91
|
-
this.deleteById(id, opts)
|
|
91
|
+
this.deleteById(id, opts),
|
|
92
92
|
);
|
|
93
93
|
|
|
94
94
|
/**
|
|
@@ -106,7 +106,7 @@ class RoleRepository extends Repository {
|
|
|
106
106
|
* @param {String} [id] - role identifier
|
|
107
107
|
*/
|
|
108
108
|
global.kuzzle.onAsk("core:security:role:invalidate", (id) =>
|
|
109
|
-
this.invalidate(id)
|
|
109
|
+
this.invalidate(id),
|
|
110
110
|
);
|
|
111
111
|
|
|
112
112
|
/**
|
|
@@ -116,7 +116,7 @@ class RoleRepository extends Repository {
|
|
|
116
116
|
* @throws If one or more roles don't exist
|
|
117
117
|
*/
|
|
118
118
|
global.kuzzle.onAsk("core:security:role:mGet", (ids) =>
|
|
119
|
-
this.loadRoles(ids)
|
|
119
|
+
this.loadRoles(ids),
|
|
120
120
|
);
|
|
121
121
|
|
|
122
122
|
/**
|
|
@@ -127,7 +127,7 @@ class RoleRepository extends Repository {
|
|
|
127
127
|
* @returns {Object} Search results
|
|
128
128
|
*/
|
|
129
129
|
global.kuzzle.onAsk("core:security:role:search", (controllers, opts) =>
|
|
130
|
-
this.searchRole(controllers, opts)
|
|
130
|
+
this.searchRole(controllers, opts),
|
|
131
131
|
);
|
|
132
132
|
|
|
133
133
|
/**
|
|
@@ -135,7 +135,7 @@ class RoleRepository extends Repository {
|
|
|
135
135
|
* @param {Object} opts (refresh)
|
|
136
136
|
*/
|
|
137
137
|
global.kuzzle.onAsk("core:security:role:truncate", (opts) =>
|
|
138
|
-
this.truncate(opts)
|
|
138
|
+
this.truncate(opts),
|
|
139
139
|
);
|
|
140
140
|
|
|
141
141
|
/**
|
|
@@ -147,7 +147,7 @@ class RoleRepository extends Repository {
|
|
|
147
147
|
* @returns {Role} Updated role
|
|
148
148
|
*/
|
|
149
149
|
global.kuzzle.onAsk("core:security:role:update", (id, content, opts) =>
|
|
150
|
-
this.update(id, content, opts)
|
|
150
|
+
this.update(id, content, opts),
|
|
151
151
|
);
|
|
152
152
|
|
|
153
153
|
/**
|
|
@@ -195,7 +195,7 @@ class RoleRepository extends Repository {
|
|
|
195
195
|
async _createOrReplace(
|
|
196
196
|
id,
|
|
197
197
|
content,
|
|
198
|
-
{ force = false, method, refresh = "false", userId = null } = {}
|
|
198
|
+
{ force = false, method, refresh = "false", userId = null } = {},
|
|
199
199
|
) {
|
|
200
200
|
const dto = {
|
|
201
201
|
...content,
|
|
@@ -319,7 +319,7 @@ class RoleRepository extends Repository {
|
|
|
319
319
|
|
|
320
320
|
const searchResults = await this.search(
|
|
321
321
|
{ query: {}, sort: [{ _id: { order: "asc" } }] },
|
|
322
|
-
{ from: 0, size: 9999 }
|
|
322
|
+
{ from: 0, size: 9999 },
|
|
323
323
|
); // /!\ NOT the options values
|
|
324
324
|
|
|
325
325
|
const result = {
|
|
@@ -330,8 +330,8 @@ class RoleRepository extends Repository {
|
|
|
330
330
|
if (body.controllers.length > 0) {
|
|
331
331
|
result.hits = searchResults.hits.filter((role) =>
|
|
332
332
|
Object.keys(role.controllers).some(
|
|
333
|
-
(key) => key === "*" || body.controllers.includes(key)
|
|
334
|
-
)
|
|
333
|
+
(key) => key === "*" || body.controllers.includes(key),
|
|
334
|
+
),
|
|
335
335
|
);
|
|
336
336
|
|
|
337
337
|
result.total = result.hits.length;
|
|
@@ -397,7 +397,7 @@ class RoleRepository extends Repository {
|
|
|
397
397
|
role._id,
|
|
398
398
|
action,
|
|
399
399
|
roleController,
|
|
400
|
-
didYouMean(action, controller.__actions)
|
|
400
|
+
didYouMean(action, controller.__actions),
|
|
401
401
|
);
|
|
402
402
|
}
|
|
403
403
|
});
|
|
@@ -428,7 +428,7 @@ class RoleRepository extends Repository {
|
|
|
428
428
|
"unknown_controller",
|
|
429
429
|
role._id,
|
|
430
430
|
roleController,
|
|
431
|
-
didYouMean(roleController, plugins.getControllerNames())
|
|
431
|
+
didYouMean(roleController, plugins.getControllerNames()),
|
|
432
432
|
);
|
|
433
433
|
}
|
|
434
434
|
|
|
@@ -439,7 +439,7 @@ class RoleRepository extends Repository {
|
|
|
439
439
|
// made after plugins controllers loading.
|
|
440
440
|
if (global.kuzzle.state === kuzzleStateEnum.RUNNING || forceWarn) {
|
|
441
441
|
global.kuzzle.log.warn(
|
|
442
|
-
`The role "${role._id}" gives access to the non-existing controller "${roleController}"
|
|
442
|
+
`The role "${role._id}" gives access to the non-existing controller "${roleController}".`,
|
|
443
443
|
);
|
|
444
444
|
}
|
|
445
445
|
|
|
@@ -455,14 +455,14 @@ class RoleRepository extends Repository {
|
|
|
455
455
|
role._id,
|
|
456
456
|
action,
|
|
457
457
|
roleController,
|
|
458
|
-
didYouMean(action, plugins.getActions(roleController))
|
|
458
|
+
didYouMean(action, plugins.getActions(roleController)),
|
|
459
459
|
);
|
|
460
460
|
}
|
|
461
461
|
|
|
462
462
|
// see the other comment
|
|
463
463
|
if (global.kuzzle.state === kuzzleStateEnum.RUNNING || forceWarn) {
|
|
464
464
|
global.kuzzle.log.warn(
|
|
465
|
-
`The role "${role._id}" gives access to the non-existing action "${action}" for the controller "${roleController}"
|
|
465
|
+
`The role "${role._id}" gives access to the non-existing action "${action}" for the controller "${roleController}".`,
|
|
466
466
|
);
|
|
467
467
|
}
|
|
468
468
|
}
|
|
@@ -510,7 +510,7 @@ class RoleRepository extends Repository {
|
|
|
510
510
|
{
|
|
511
511
|
from: 0,
|
|
512
512
|
size: 1,
|
|
513
|
-
}
|
|
513
|
+
},
|
|
514
514
|
);
|
|
515
515
|
|
|
516
516
|
if (response.total > 0) {
|
|
@@ -41,7 +41,7 @@ class SecurityLoader {
|
|
|
41
41
|
* @param {Object} opts - force, onExistingUsers (fail), onExistingUsersWarning (false), user (null)
|
|
42
42
|
*/
|
|
43
43
|
global.kuzzle.onAsk("core:security:load", (json, opts) =>
|
|
44
|
-
this.load(json, opts)
|
|
44
|
+
this.load(json, opts),
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -53,7 +53,7 @@ class SecurityLoader {
|
|
|
53
53
|
onExistingUsersWarning = false,
|
|
54
54
|
refresh = "false",
|
|
55
55
|
user = null,
|
|
56
|
-
} = {}
|
|
56
|
+
} = {},
|
|
57
57
|
) {
|
|
58
58
|
assertIsObject(permissions);
|
|
59
59
|
|
|
@@ -67,7 +67,7 @@ class SecurityLoader {
|
|
|
67
67
|
"createOrReplaceProfile",
|
|
68
68
|
permissions.profiles,
|
|
69
69
|
"profiles",
|
|
70
|
-
{ refresh, user }
|
|
70
|
+
{ refresh, user },
|
|
71
71
|
);
|
|
72
72
|
|
|
73
73
|
const usersToLoad = await this._getUsersToLoad(permissions.users, {
|
|
@@ -99,7 +99,7 @@ class SecurityLoader {
|
|
|
99
99
|
force,
|
|
100
100
|
refresh,
|
|
101
101
|
},
|
|
102
|
-
{ user }
|
|
102
|
+
{ user },
|
|
103
103
|
);
|
|
104
104
|
|
|
105
105
|
promises.push(global.kuzzle.funnel.processRequest(request));
|
|
@@ -135,7 +135,7 @@ class SecurityLoader {
|
|
|
135
135
|
} else if (onExistingUsers === "skip") {
|
|
136
136
|
if (warning) {
|
|
137
137
|
global.kuzzle.log.info(
|
|
138
|
-
`Users skipped during import: ${existingUserIds}
|
|
138
|
+
`Users skipped during import: ${existingUserIds}`,
|
|
139
139
|
);
|
|
140
140
|
}
|
|
141
141
|
return Object.entries(users).reduce((memo, [userId, content]) => {
|
|
@@ -148,7 +148,7 @@ class SecurityLoader {
|
|
|
148
148
|
} else if (onExistingUsers === "overwrite") {
|
|
149
149
|
if (warning) {
|
|
150
150
|
global.kuzzle.log.info(
|
|
151
|
-
`Users overwritten during import: ${existingUserIds}
|
|
151
|
+
`Users overwritten during import: ${existingUserIds}`,
|
|
152
152
|
);
|
|
153
153
|
}
|
|
154
154
|
const mDeleteUsers = new Request({
|
|
@@ -167,7 +167,7 @@ class SecurityLoader {
|
|
|
167
167
|
"assert",
|
|
168
168
|
"unexpected_argument",
|
|
169
169
|
"onExistingUsers",
|
|
170
|
-
["skip", "overwrite", "fail"]
|
|
170
|
+
["skip", "overwrite", "fail"],
|
|
171
171
|
);
|
|
172
172
|
}
|
|
173
173
|
}
|
|
@@ -58,7 +58,7 @@ class UserRepository extends Repository {
|
|
|
58
58
|
*/
|
|
59
59
|
global.kuzzle.onAsk(
|
|
60
60
|
"core:security:user:anonymous:get",
|
|
61
|
-
() => this.anonymousUser
|
|
61
|
+
() => this.anonymousUser,
|
|
62
62
|
);
|
|
63
63
|
|
|
64
64
|
/**
|
|
@@ -73,7 +73,7 @@ class UserRepository extends Repository {
|
|
|
73
73
|
global.kuzzle.onAsk(
|
|
74
74
|
"core:security:user:create",
|
|
75
75
|
(id, profileIds, content, opts) =>
|
|
76
|
-
this.create(id, profileIds, content, opts)
|
|
76
|
+
this.create(id, profileIds, content, opts),
|
|
77
77
|
);
|
|
78
78
|
|
|
79
79
|
/**
|
|
@@ -83,7 +83,7 @@ class UserRepository extends Repository {
|
|
|
83
83
|
* @throws If the user doesn't exist
|
|
84
84
|
*/
|
|
85
85
|
global.kuzzle.onAsk("core:security:user:delete", (id, opts) =>
|
|
86
|
-
this.deleteById(id, opts)
|
|
86
|
+
this.deleteById(id, opts),
|
|
87
87
|
);
|
|
88
88
|
|
|
89
89
|
/**
|
|
@@ -101,7 +101,7 @@ class UserRepository extends Repository {
|
|
|
101
101
|
* @throws If one or more users don't exist
|
|
102
102
|
*/
|
|
103
103
|
global.kuzzle.onAsk("core:security:user:mGet", (ids) =>
|
|
104
|
-
this.loadMultiFromDatabase(ids)
|
|
104
|
+
this.loadMultiFromDatabase(ids),
|
|
105
105
|
);
|
|
106
106
|
|
|
107
107
|
/**
|
|
@@ -114,7 +114,7 @@ class UserRepository extends Repository {
|
|
|
114
114
|
global.kuzzle.onAsk(
|
|
115
115
|
"core:security:user:replace",
|
|
116
116
|
(id, profileIds, content, opts) =>
|
|
117
|
-
this.replace(id, profileIds, content, opts)
|
|
117
|
+
this.replace(id, profileIds, content, opts),
|
|
118
118
|
);
|
|
119
119
|
|
|
120
120
|
/**
|
|
@@ -124,7 +124,7 @@ class UserRepository extends Repository {
|
|
|
124
124
|
* @returns {Object} Search results
|
|
125
125
|
*/
|
|
126
126
|
global.kuzzle.onAsk("core:security:user:scroll", (id, ttl) =>
|
|
127
|
-
this.scroll(id, ttl)
|
|
127
|
+
this.scroll(id, ttl),
|
|
128
128
|
);
|
|
129
129
|
|
|
130
130
|
/**
|
|
@@ -134,7 +134,7 @@ class UserRepository extends Repository {
|
|
|
134
134
|
* @returns {Object} Search results
|
|
135
135
|
*/
|
|
136
136
|
global.kuzzle.onAsk("core:security:user:search", (searchBody, opts) =>
|
|
137
|
-
this.search(searchBody, opts)
|
|
137
|
+
this.search(searchBody, opts),
|
|
138
138
|
);
|
|
139
139
|
|
|
140
140
|
/**
|
|
@@ -142,7 +142,7 @@ class UserRepository extends Repository {
|
|
|
142
142
|
* @param {Object} opts (refresh)
|
|
143
143
|
*/
|
|
144
144
|
global.kuzzle.onAsk("core:security:user:truncate", (opts) =>
|
|
145
|
-
this.truncate(opts)
|
|
145
|
+
this.truncate(opts),
|
|
146
146
|
);
|
|
147
147
|
|
|
148
148
|
/**
|
|
@@ -155,7 +155,7 @@ class UserRepository extends Repository {
|
|
|
155
155
|
global.kuzzle.onAsk(
|
|
156
156
|
"core:security:user:update",
|
|
157
157
|
(id, profileIds, content, opts) =>
|
|
158
|
-
this.update(id, profileIds, content, opts)
|
|
158
|
+
this.update(id, profileIds, content, opts),
|
|
159
159
|
);
|
|
160
160
|
|
|
161
161
|
/**
|
|
@@ -164,7 +164,7 @@ class UserRepository extends Repository {
|
|
|
164
164
|
* @returns {Boolean}
|
|
165
165
|
*/
|
|
166
166
|
global.kuzzle.onAsk("core:security:user:admin:exist", () =>
|
|
167
|
-
this.adminExists()
|
|
167
|
+
this.adminExists(),
|
|
168
168
|
);
|
|
169
169
|
}
|
|
170
170
|
|
|
@@ -216,7 +216,7 @@ class UserRepository extends Repository {
|
|
|
216
216
|
id,
|
|
217
217
|
profileIds,
|
|
218
218
|
content,
|
|
219
|
-
{ refresh = "false", retryOnConflict = 10, userId } = {}
|
|
219
|
+
{ refresh = "false", retryOnConflict = 10, userId } = {},
|
|
220
220
|
) {
|
|
221
221
|
const user = await this.load(id);
|
|
222
222
|
const pojo = this.toDTO(user);
|
|
@@ -374,7 +374,7 @@ class UserRepository extends Repository {
|
|
|
374
374
|
for (const strategy of availableStrategies) {
|
|
375
375
|
const existStrategy = global.kuzzle.pluginsManager.getStrategyMethod(
|
|
376
376
|
strategy,
|
|
377
|
-
"exists"
|
|
377
|
+
"exists",
|
|
378
378
|
);
|
|
379
379
|
|
|
380
380
|
if (await existStrategy(request, user._id, strategy)) {
|
|
@@ -387,7 +387,7 @@ class UserRepository extends Repository {
|
|
|
387
387
|
for (const strategy of userStrategies) {
|
|
388
388
|
const deleteStrategy = global.kuzzle.pluginsManager.getStrategyMethod(
|
|
389
389
|
strategy,
|
|
390
|
-
"delete"
|
|
390
|
+
"delete",
|
|
391
391
|
);
|
|
392
392
|
|
|
393
393
|
// We catch any error produced by delete as we want to make as much
|
|
@@ -396,7 +396,7 @@ class UserRepository extends Repository {
|
|
|
396
396
|
debug(
|
|
397
397
|
"Deleting credentials on strategy %s for user %s",
|
|
398
398
|
strategy,
|
|
399
|
-
user._id
|
|
399
|
+
user._id,
|
|
400
400
|
);
|
|
401
401
|
await deleteStrategy(request, user._id, strategy);
|
|
402
402
|
} catch (error) {
|
|
@@ -410,7 +410,7 @@ class UserRepository extends Repository {
|
|
|
410
410
|
"security",
|
|
411
411
|
"credentials",
|
|
412
412
|
"rejected",
|
|
413
|
-
errors.join("\n\t- ")
|
|
413
|
+
errors.join("\n\t- "),
|
|
414
414
|
);
|
|
415
415
|
}
|
|
416
416
|
}
|
|
@@ -436,7 +436,7 @@ class UserRepository extends Repository {
|
|
|
436
436
|
term: { profileIds: "admin" },
|
|
437
437
|
},
|
|
438
438
|
},
|
|
439
|
-
{ size: 1 }
|
|
439
|
+
{ size: 1 },
|
|
440
440
|
);
|
|
441
441
|
|
|
442
442
|
return total >= 1;
|