kuzzle 2.57.0-beta.2 → 2.57.0-beta.3
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/dist/lib/core/network/accessLogger.d.ts +1 -0
- package/dist/lib/core/network/accessLogger.js +13 -2
- package/dist/lib/model/storage/apiKey.d.ts +8 -0
- package/dist/lib/model/storage/apiKey.js +25 -0
- package/dist/lib/model/storage/baseModel.d.ts +1 -1
- package/dist/lib/model/storage/baseModel.js +0 -1
- package/dist/package.json +3 -3
- package/package.json +3 -3
|
@@ -51,6 +51,7 @@ exports.AccessLoggerWorker = exports.AccessLogger = void 0;
|
|
|
51
51
|
// efficient CPU resources management, and more performances in the end
|
|
52
52
|
const node_worker_threads_1 = require("node:worker_threads");
|
|
53
53
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
54
|
+
const lodash_1 = require("lodash");
|
|
54
55
|
const moment_1 = __importDefault(require("moment"));
|
|
55
56
|
const pino = __importStar(require("pino"));
|
|
56
57
|
const request_1 = require("../../api/request");
|
|
@@ -207,10 +208,14 @@ class AccessLoggerWorker {
|
|
|
207
208
|
logAccess(connection, request, size, extra = null) {
|
|
208
209
|
if (this.config.logs.accessLogFormat === "logstash") {
|
|
209
210
|
// custom kuzzle logs to be exported to logstash
|
|
211
|
+
// The request headers are logged once, under `extra.headers`, where
|
|
212
|
+
// v2.56.0 already logged them (its connections had no headers): the
|
|
213
|
+
// same values under `connection` and `extra.connection` only tripled
|
|
214
|
+
// the size of every entry.
|
|
210
215
|
this.logger.info({
|
|
211
|
-
connection,
|
|
216
|
+
connection: (0, lodash_1.omit)(connection, "headers"),
|
|
212
217
|
error: request.error,
|
|
213
|
-
extra,
|
|
218
|
+
extra: withoutConnectionHeaders(extra),
|
|
214
219
|
namespace: "kuzzle:accessLogs",
|
|
215
220
|
nodeId: global.kuzzle.id,
|
|
216
221
|
request: request.input,
|
|
@@ -271,6 +276,12 @@ class AccessLoggerWorker {
|
|
|
271
276
|
}
|
|
272
277
|
}
|
|
273
278
|
exports.AccessLoggerWorker = AccessLoggerWorker;
|
|
279
|
+
function withoutConnectionHeaders(extra) {
|
|
280
|
+
if (!extra?.connection) {
|
|
281
|
+
return extra;
|
|
282
|
+
}
|
|
283
|
+
return { ...extra, connection: (0, lodash_1.omit)(extra.connection, "headers") };
|
|
284
|
+
}
|
|
274
285
|
/**
|
|
275
286
|
* For protocols other than http, we rebuild a pseudo url out of the request's
|
|
276
287
|
* controller, action and arguments.
|
|
@@ -57,6 +57,14 @@ declare class ApiKey extends BaseModel {
|
|
|
57
57
|
* @param fingerprint - API key fingerprint
|
|
58
58
|
*/
|
|
59
59
|
static loadByFingerprint(userId: string, fingerprint: string): Promise<ApiKey>;
|
|
60
|
+
/**
|
|
61
|
+
* Finds a user's API key by comparing the fingerprint stored in each of
|
|
62
|
+
* their keys, for collections where `fingerprint` is not indexed.
|
|
63
|
+
*
|
|
64
|
+
* @param userId - User ID
|
|
65
|
+
* @param fingerprint - API key fingerprint
|
|
66
|
+
*/
|
|
67
|
+
static scanByFingerprint(userId: string, fingerprint: string): Promise<ApiKey | null>;
|
|
60
68
|
/**
|
|
61
69
|
* Loads a user's API key from a request, identified by its `_id`, its
|
|
62
70
|
* clear-text `key` or its `fingerprint` (in that order of precedence).
|
|
@@ -156,6 +156,14 @@ class ApiKey extends baseModel_1.default {
|
|
|
156
156
|
},
|
|
157
157
|
}, { size: 1 });
|
|
158
158
|
if (!apiKey) {
|
|
159
|
+
// An install upgraded from a version without the `fingerprint` mapping
|
|
160
|
+
// keeps its old one (existing internal collections are never
|
|
161
|
+
// re-mapped), so the term query above finds nothing there — for any key.
|
|
162
|
+
// Every key stores its fingerprint in `_source`, so scan the user's keys.
|
|
163
|
+
const scanned = await this.scanByFingerprint(userId, fingerprint);
|
|
164
|
+
if (scanned) {
|
|
165
|
+
return scanned;
|
|
166
|
+
}
|
|
159
167
|
throw kerror.get("services", "storage", "not_found", fingerprint, {
|
|
160
168
|
message: `ApiKey with fingerprint "${fingerprint}" not found for user "${userId}".`,
|
|
161
169
|
});
|
|
@@ -163,6 +171,23 @@ class ApiKey extends baseModel_1.default {
|
|
|
163
171
|
// @ts-expect-error We fetch from the api key collection so this is safe
|
|
164
172
|
return apiKey;
|
|
165
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Finds a user's API key by comparing the fingerprint stored in each of
|
|
176
|
+
* their keys, for collections where `fingerprint` is not indexed.
|
|
177
|
+
*
|
|
178
|
+
* @param userId - User ID
|
|
179
|
+
* @param fingerprint - API key fingerprint
|
|
180
|
+
*/
|
|
181
|
+
static async scanByFingerprint(userId, fingerprint) {
|
|
182
|
+
let foundId = null;
|
|
183
|
+
await this.batchExecute({ term: { userId } }, (hits) => {
|
|
184
|
+
const hit = hits.find((document) => document._source.fingerprint === fingerprint);
|
|
185
|
+
if (hit && !foundId) {
|
|
186
|
+
foundId = hit._id;
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
return foundId ? this.load(userId, foundId) : null;
|
|
190
|
+
}
|
|
166
191
|
/**
|
|
167
192
|
* Loads a user's API key from a request, identified by its `_id`, its
|
|
168
193
|
* clear-text `key` or its `fingerprint` (in that order of precedence).
|
|
@@ -92,7 +92,7 @@ declare class BaseModel {
|
|
|
92
92
|
static truncate({ refresh, }?: {
|
|
93
93
|
refresh?: boolean | string;
|
|
94
94
|
}): Promise<void>;
|
|
95
|
-
static batchExecute(query: JSONObject, callback: (
|
|
95
|
+
static batchExecute(query: JSONObject, callback: (hits: StorageDocument[]) => unknown): Promise<any>;
|
|
96
96
|
/**
|
|
97
97
|
* Must be overriden by children
|
|
98
98
|
*/
|
|
@@ -166,7 +166,6 @@ class BaseModel {
|
|
|
166
166
|
static truncate({ refresh, } = {}) {
|
|
167
167
|
return this.deleteByQuery({ match_all: {} }, { refresh });
|
|
168
168
|
}
|
|
169
|
-
// ? This looks not in use anymore ?
|
|
170
169
|
static batchExecute(query, callback) {
|
|
171
170
|
return global.kuzzle.internalIndex.mExecute(this.collection, query, callback);
|
|
172
171
|
}
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kuzzle",
|
|
3
3
|
"author": "The Kuzzle Team <support@kuzzle.io>",
|
|
4
|
-
"version": "2.57.0-beta.
|
|
4
|
+
"version": "2.57.0-beta.3",
|
|
5
5
|
"description": "Kuzzle is an open-source solution that handles all the data management through a secured API, with a large choice of protocols.",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "rm -Rf ./dist && tsc && node -r ts-node/register/transpile-only ./bin/copy-binaries.ts",
|
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
"lib": "lib"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
+
"@types/bluebird": "3.5.42",
|
|
36
|
+
"@types/passport": "1.0.17",
|
|
35
37
|
"aedes": "0.51.3",
|
|
36
38
|
"bluebird": "3.7.2",
|
|
37
39
|
"cli-color": "2.0.4",
|
|
@@ -83,10 +85,8 @@
|
|
|
83
85
|
"devDependencies": {
|
|
84
86
|
"@cucumber/cucumber": "12.5.0",
|
|
85
87
|
"@types/async": "^3.2.24",
|
|
86
|
-
"@types/bluebird": "3.5.42",
|
|
87
88
|
"@types/cookie": "1.0.0",
|
|
88
89
|
"@types/lodash": "4.17.21",
|
|
89
|
-
"@types/passport": "1.0.17",
|
|
90
90
|
"@types/validator": "^13.15.10",
|
|
91
91
|
"@types/yargs": "17.0.35",
|
|
92
92
|
"@vitest/coverage-v8": "4.0.16",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kuzzle",
|
|
3
3
|
"author": "The Kuzzle Team <support@kuzzle.io>",
|
|
4
|
-
"version": "2.57.0-beta.
|
|
4
|
+
"version": "2.57.0-beta.3",
|
|
5
5
|
"description": "Kuzzle is an open-source solution that handles all the data management through a secured API, with a large choice of protocols.",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "rm -Rf ./dist && tsc && node -r ts-node/register/transpile-only ./bin/copy-binaries.ts",
|
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
"lib": "lib"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
+
"@types/bluebird": "3.5.42",
|
|
36
|
+
"@types/passport": "1.0.17",
|
|
35
37
|
"aedes": "0.51.3",
|
|
36
38
|
"bluebird": "3.7.2",
|
|
37
39
|
"cli-color": "2.0.4",
|
|
@@ -83,10 +85,8 @@
|
|
|
83
85
|
"devDependencies": {
|
|
84
86
|
"@cucumber/cucumber": "12.5.0",
|
|
85
87
|
"@types/async": "^3.2.24",
|
|
86
|
-
"@types/bluebird": "3.5.42",
|
|
87
88
|
"@types/cookie": "1.0.0",
|
|
88
89
|
"@types/lodash": "4.17.21",
|
|
89
|
-
"@types/passport": "1.0.17",
|
|
90
90
|
"@types/validator": "^13.15.10",
|
|
91
91
|
"@types/yargs": "17.0.35",
|
|
92
92
|
"@vitest/coverage-v8": "4.0.16",
|