kuzzle 2.60.0-beta.1 → 2.60.0-beta.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/dist/bin/copy-binaries.js +17 -7
- package/dist/bin/start-kuzzle-server +17 -7
- package/dist/index.d.ts +2 -1
- package/dist/index.js +6 -2
- package/dist/lib/api/controllers/adminController.d.ts +9 -3
- package/dist/lib/api/controllers/adminController.js +42 -26
- package/dist/lib/api/controllers/authController.d.ts +15 -5
- package/dist/lib/api/controllers/authController.js +35 -20
- package/dist/lib/api/controllers/baseController.js +17 -7
- package/dist/lib/api/controllers/bulkController.js +17 -7
- package/dist/lib/api/controllers/collectionController.js +17 -7
- package/dist/lib/api/controllers/debugController.js +17 -7
- package/dist/lib/api/controllers/documentController.js +17 -7
- package/dist/lib/api/controllers/indexController.d.ts +1 -1
- package/dist/lib/api/controllers/memoryStorageController.js +17 -7
- package/dist/lib/api/controllers/securityController.d.ts +30 -28
- package/dist/lib/api/controllers/securityController.js +18 -8
- package/dist/lib/api/controllers/serverController.d.ts +0 -1
- package/dist/lib/api/controllers/serverController.js +17 -7
- package/dist/lib/api/documentExtractor.js +17 -7
- package/dist/lib/api/funnel.js +19 -9
- package/dist/lib/api/httpRoutes.d.ts +2 -1
- package/dist/lib/api/openapi/OpenApiManager.d.ts +2 -1
- package/dist/lib/api/openapi/openApiGenerator.js +1 -2
- package/dist/lib/api/request/kuzzleRequest.d.ts +9 -2
- package/dist/lib/api/request/kuzzleRequest.js +21 -7
- package/dist/lib/api/request/requestContext.d.ts +7 -2
- package/dist/lib/api/request/requestContext.js +17 -7
- package/dist/lib/api/request/requestInput.d.ts +1 -1
- package/dist/lib/api/request/requestInput.js +17 -7
- package/dist/lib/api/request/requestResponse.d.ts +2 -2
- package/dist/lib/api/request/requestResponse.js +21 -10
- package/dist/lib/cluster/command.d.ts +0 -2
- package/dist/lib/cluster/command.js +17 -7
- package/dist/lib/cluster/idCardHandler.d.ts +3 -2
- package/dist/lib/cluster/idCardHandler.js +1 -1
- package/dist/lib/cluster/node.js +69 -64
- package/dist/lib/cluster/protobuf/command.proto +23 -22
- package/dist/lib/cluster/protobuf/sync.proto +91 -85
- package/dist/lib/cluster/publisher.js +17 -7
- package/dist/lib/cluster/state.js +17 -7
- package/dist/lib/cluster/subscriber.d.ts +0 -2
- package/dist/lib/cluster/subscriber.js +17 -7
- package/dist/lib/cluster/workers/IDCardRenewer.d.ts +0 -1
- package/dist/lib/config/index.js +20 -14
- package/dist/lib/core/auth/formatProcessing.d.ts +1 -1
- package/dist/lib/core/auth/formatProcessing.js +3 -3
- package/dist/lib/core/auth/passportResponse.d.ts +0 -1
- package/dist/lib/core/auth/passportWrapper.js +22 -8
- package/dist/lib/core/backend/backend.js +17 -7
- package/dist/lib/core/backend/backendConfig.d.ts +1 -1
- package/dist/lib/core/backend/backendConfig.js +17 -7
- package/dist/lib/core/backend/backendController.js +17 -7
- package/dist/lib/core/backend/backendErrors.js +17 -7
- package/dist/lib/core/backend/backendHook.js +17 -7
- package/dist/lib/core/backend/backendImport.js +17 -7
- package/dist/lib/core/backend/backendPipe.d.ts +4 -1
- package/dist/lib/core/backend/backendPipe.js +17 -7
- package/dist/lib/core/backend/backendPlugin.js +17 -7
- package/dist/lib/core/backend/backendStorage.js +8 -8
- package/dist/lib/core/backend/backendSubscription.js +17 -7
- package/dist/lib/core/backend/backendVault.js +17 -7
- package/dist/lib/core/backend/internalLogger.d.ts +7 -7
- package/dist/lib/core/debug/kuzzleDebugger.js +17 -7
- package/dist/lib/core/network/accessLogger.d.ts +0 -1
- package/dist/lib/core/network/accessLogger.js +17 -7
- package/dist/lib/core/network/clientConnection.js +17 -7
- package/dist/lib/core/network/context.d.ts +0 -1
- package/dist/lib/core/network/entryPoint.js +17 -7
- package/dist/lib/core/network/httpRouter/routePart.js +17 -7
- package/dist/lib/core/network/protocols/httpMessage.d.ts +0 -2
- package/dist/lib/core/network/protocols/httpwsProtocol.d.ts +0 -3
- package/dist/lib/core/network/protocols/httpwsProtocol.js +17 -7
- package/dist/lib/core/network/protocols/mqttProtocol.d.ts +1 -2
- package/dist/lib/core/network/protocols/mqttProtocol.js +31 -10
- package/dist/lib/core/network/router.js +17 -7
- package/dist/lib/core/plugin/plugin.js +17 -7
- package/dist/lib/core/plugin/pluginContext.d.ts +20 -9
- package/dist/lib/core/plugin/pluginContext.js +39 -24
- package/dist/lib/core/plugin/pluginsManager.js +17 -7
- package/dist/lib/core/realtime/channel.js +17 -7
- package/dist/lib/core/realtime/hotelClerk.d.ts +3 -2
- package/dist/lib/core/realtime/hotelClerk.js +17 -7
- package/dist/lib/core/realtime/notifier.js +17 -7
- package/dist/lib/core/security/profileRepository.js +17 -7
- package/dist/lib/core/security/roleRepository.js +17 -7
- package/dist/lib/core/security/securityLoader.js +17 -7
- package/dist/lib/core/security/tokenRepository.js +18 -8
- package/dist/lib/core/security/userRepository.js +17 -7
- package/dist/lib/core/shared/ObjectRepository.js +20 -7
- package/dist/lib/core/shared/abstractManifest.js +17 -7
- package/dist/lib/core/shared/sdk/embeddedSdk.js +20 -8
- package/dist/lib/core/shared/sdk/funnelProtocol.js +17 -7
- package/dist/lib/core/shared/store.d.ts +11 -1
- package/dist/lib/core/shared/store.js +26 -30
- package/dist/lib/core/statistics/statistics.d.ts +0 -1
- package/dist/lib/core/statistics/statistics.js +17 -7
- package/dist/lib/core/storage/clientAdapter.d.ts +4 -6
- package/dist/lib/core/storage/clientAdapter.js +24 -18
- package/dist/lib/core/storage/indexCache.js +17 -7
- package/dist/lib/core/validation/specification.js +1 -2
- package/dist/lib/core/validation/types/date.js +17 -7
- package/dist/lib/core/validation/types/enum.js +17 -7
- package/dist/lib/core/validation/types/geoShape.js +17 -7
- package/dist/lib/core/validation/types/geoShapeUtils.js +6 -7
- package/dist/lib/core/validation/validation.js +17 -7
- package/dist/lib/core/validation/validationUtils.js +24 -15
- package/dist/lib/kerror/codes/index.js +20 -10
- package/dist/lib/kerror/errors/kuzzleError.js +18 -8
- package/dist/lib/kerror/index.js +31 -18
- package/dist/lib/kuzzle/Logger.js +4 -3
- package/dist/lib/kuzzle/dumpGenerator.js +17 -7
- package/dist/lib/kuzzle/event/KuzzleEventEmitter.d.ts +3 -3
- package/dist/lib/kuzzle/event/KuzzleEventEmitter.js +17 -7
- package/dist/lib/kuzzle/event/pipeRunner.js +17 -7
- package/dist/lib/kuzzle/internalIndexHandler.js +37 -32
- package/dist/lib/kuzzle/kuzzle.d.ts +13 -8
- package/dist/lib/kuzzle/kuzzle.js +103 -128
- package/dist/lib/model/security/profile.js +17 -7
- package/dist/lib/model/security/role.js +17 -7
- package/dist/lib/model/security/user.js +17 -7
- package/dist/lib/model/storage/apiKey.d.ts +1 -1
- package/dist/lib/model/storage/apiKey.js +17 -7
- package/dist/lib/service/cache/redis.js +40 -9
- package/dist/lib/service/service.js +17 -7
- package/dist/lib/service/storage/7/elasticsearch.d.ts +36 -25
- package/dist/lib/service/storage/7/elasticsearch.js +73 -55
- package/dist/lib/service/storage/8/elasticsearch.d.ts +47 -36
- package/dist/lib/service/storage/8/elasticsearch.js +73 -55
- package/dist/lib/service/storage/Elasticsearch.d.ts +10 -4
- package/dist/lib/types/HttpStream.d.ts +0 -1
- package/dist/lib/types/Plugin.js +17 -7
- package/dist/lib/types/config/SecurityConfiguration.d.ts +0 -2
- package/dist/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.d.ts +5 -0
- package/dist/lib/types/controllers/GetCurrentUserResponse.d.ts +5 -0
- package/dist/lib/types/controllers/GetCurrentUserResponse.js +3 -0
- package/dist/lib/types/controllers/ResetSecurityResult.d.ts +5 -0
- package/dist/lib/types/controllers/ResetSecurityResult.js +3 -0
- package/dist/lib/types/controllers/adminController.type.d.ts +7 -5
- package/dist/lib/types/controllers/authController.type.d.ts +7 -5
- package/dist/lib/types/core/auth/Serialized.d.ts +14 -0
- package/dist/lib/types/core/auth/Serialized.js +3 -0
- package/dist/lib/types/core/auth/formatProcessing.type.d.ts +5 -11
- package/dist/lib/types/events/EventProtocol.d.ts +0 -2
- package/dist/lib/types/index.d.ts +1 -0
- package/dist/lib/types/index.js +1 -0
- package/dist/lib/types/storage/8/Elasticsearch.d.ts +4 -3
- package/dist/lib/util/array.d.ts +1 -1
- package/dist/lib/util/array.js +7 -6
- package/dist/lib/util/assertType.js +5 -6
- package/dist/lib/util/async.js +1 -2
- package/dist/lib/util/asyncStore.d.ts +0 -1
- package/dist/lib/util/bufferedPassThrough.d.ts +0 -3
- package/dist/lib/util/crypto.js +1 -2
- package/dist/lib/util/debug.d.ts +0 -1
- package/dist/lib/util/debug.js +17 -7
- package/dist/lib/util/distributedLock.d.ts +27 -4
- package/dist/lib/util/distributedLock.js +69 -16
- package/dist/lib/util/dump-collection.d.ts +2 -2
- package/dist/lib/util/dump-collection.js +22 -13
- package/dist/lib/util/esRequest.js +1 -2
- package/dist/lib/util/extractFields.d.ts +16 -7
- package/dist/lib/util/extractFields.js +1 -10
- package/dist/lib/util/koncordeCompat.js +22 -13
- package/dist/lib/util/mutex.d.ts +4 -4
- package/dist/lib/util/mutex.js +21 -11
- package/dist/lib/util/name-generator.js +2 -2
- package/dist/lib/util/requestAssertions.js +27 -18
- package/dist/lib/util/safeObject.js +3 -4
- package/dist/lib/util/stackTrace.js +2 -3
- package/dist/lib/util/thrown.js +1 -2
- package/dist/lib/util/time.js +1 -2
- package/dist/package.json +22 -15
- package/package.json +22 -15
|
@@ -36,13 +36,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
36
36
|
}) : function(o, v) {
|
|
37
37
|
o["default"] = v;
|
|
38
38
|
});
|
|
39
|
-
var __importStar = (this && this.__importStar) || function (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
};
|
|
39
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
40
|
+
var ownKeys = function(o) {
|
|
41
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
42
|
+
var ar = [];
|
|
43
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
44
|
+
return ar;
|
|
45
|
+
};
|
|
46
|
+
return ownKeys(o);
|
|
47
|
+
};
|
|
48
|
+
return function (mod) {
|
|
49
|
+
if (mod && mod.__esModule) return mod;
|
|
50
|
+
var result = {};
|
|
51
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
52
|
+
__setModuleDefault(result, mod);
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
46
56
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
57
|
/**
|
|
48
58
|
* Second half of `npm run build`: `tsc` emits the compiled JavaScript, this
|
|
@@ -36,13 +36,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
36
36
|
}) : function(o, v) {
|
|
37
37
|
o["default"] = v;
|
|
38
38
|
});
|
|
39
|
-
var __importStar = (this && this.__importStar) || function (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
};
|
|
39
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
40
|
+
var ownKeys = function(o) {
|
|
41
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
42
|
+
var ar = [];
|
|
43
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
44
|
+
return ar;
|
|
45
|
+
};
|
|
46
|
+
return ownKeys(o);
|
|
47
|
+
};
|
|
48
|
+
return function (mod) {
|
|
49
|
+
if (mod && mod.__esModule) return mod;
|
|
50
|
+
var result = {};
|
|
51
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
52
|
+
__setModuleDefault(result, mod);
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
46
56
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
47
57
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
58
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export * from "./lib/core/shared/sdk/embeddedSdk";
|
|
|
5
5
|
export * from "./lib/api/request";
|
|
6
6
|
export * from "./lib/kerror/errors";
|
|
7
7
|
export * from "./lib/util/mutex";
|
|
8
|
-
export
|
|
8
|
+
export { MutexAcquireError, MutexLockLostError, withLock, } from "./lib/util/distributedLock";
|
|
9
|
+
export type { MutexConfig } from "./lib/util/distributedLock";
|
|
9
10
|
export * from "./lib/util/Inflector";
|
|
10
11
|
export { NameGenerator } from "./lib/util/name-generator";
|
|
11
12
|
export type {
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.WebSocket = exports.UserSearchResult = exports.UserOption = exports.User = exports.SpecificationsSearchResult = exports.ServerController = exports.SearchResultBase = exports.ScopeOption = exports.RoleSearchResult = exports.Role = exports.RealtimeDocument = exports.RealtimeController = exports.ProfileSearchResult = exports.Profile = exports.Observer = exports.KuzzleEventEmitter = exports.KuzzleAbstractProtocol = exports.Kuzzle = exports.IndexController = exports.Http = exports.DocumentSearchResult = exports.DocumentController = exports.Document = exports.CollectionController = exports.BatchController = exports.BaseController = exports.AuthController = exports.NameGenerator = void 0;
|
|
17
|
+
exports.WebSocket = exports.UserSearchResult = exports.UserOption = exports.User = exports.SpecificationsSearchResult = exports.ServerController = exports.SearchResultBase = exports.ScopeOption = exports.RoleSearchResult = exports.Role = exports.RealtimeDocument = exports.RealtimeController = exports.ProfileSearchResult = exports.Profile = exports.Observer = exports.KuzzleEventEmitter = exports.KuzzleAbstractProtocol = exports.Kuzzle = exports.IndexController = exports.Http = exports.DocumentSearchResult = exports.DocumentController = exports.Document = exports.CollectionController = exports.BatchController = exports.BaseController = exports.AuthController = exports.NameGenerator = exports.withLock = exports.MutexLockLostError = exports.MutexAcquireError = void 0;
|
|
18
18
|
__exportStar(require("./lib/core/backend"), exports);
|
|
19
19
|
__exportStar(require("./lib/types"), exports);
|
|
20
20
|
__exportStar(require("./lib/core/plugin/pluginContext"), exports);
|
|
@@ -22,7 +22,11 @@ __exportStar(require("./lib/core/shared/sdk/embeddedSdk"), exports);
|
|
|
22
22
|
__exportStar(require("./lib/api/request"), exports);
|
|
23
23
|
__exportStar(require("./lib/kerror/errors"), exports);
|
|
24
24
|
__exportStar(require("./lib/util/mutex"), exports);
|
|
25
|
-
|
|
25
|
+
// Explicit: `releaseAllLocksBeforeExit` is internal to Kuzzle's shutdown
|
|
26
|
+
var distributedLock_1 = require("./lib/util/distributedLock");
|
|
27
|
+
Object.defineProperty(exports, "MutexAcquireError", { enumerable: true, get: function () { return distributedLock_1.MutexAcquireError; } });
|
|
28
|
+
Object.defineProperty(exports, "MutexLockLostError", { enumerable: true, get: function () { return distributedLock_1.MutexLockLostError; } });
|
|
29
|
+
Object.defineProperty(exports, "withLock", { enumerable: true, get: function () { return distributedLock_1.withLock; } });
|
|
26
30
|
__exportStar(require("./lib/util/Inflector"), exports);
|
|
27
31
|
var name_generator_1 = require("./lib/util/name-generator");
|
|
28
32
|
Object.defineProperty(exports, "NameGenerator", { enumerable: true, get: function () { return name_generator_1.NameGenerator; } });
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { NativeController } from "./baseController";
|
|
2
2
|
import type { KuzzleRequest } from "../request";
|
|
3
|
-
import type { ResetSecurityResult } from "../../types/controllers/
|
|
3
|
+
import type { ResetSecurityResult } from "../../types/controllers/ResetSecurityResult";
|
|
4
|
+
import type { KuzzleLogger } from "kuzzle-logger";
|
|
4
5
|
/**
|
|
5
6
|
* @class AdminController
|
|
6
7
|
*/
|
|
7
8
|
declare class AdminController extends NativeController {
|
|
8
9
|
protected shuttingDown: boolean;
|
|
9
|
-
protected logger:
|
|
10
|
+
protected logger: KuzzleLogger;
|
|
10
11
|
constructor();
|
|
11
12
|
refreshIndexCache(): Promise<void>;
|
|
12
13
|
/**
|
|
@@ -25,6 +26,11 @@ declare class AdminController extends NativeController {
|
|
|
25
26
|
resetDatabase(): Promise<{
|
|
26
27
|
acknowledge: boolean;
|
|
27
28
|
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Runs `callback` under the `resource` lock, or refuses the action right
|
|
31
|
+
* away if another node or request already holds it
|
|
32
|
+
*/
|
|
33
|
+
private failIfLocked;
|
|
28
34
|
/**
|
|
29
35
|
* Generate a dump
|
|
30
36
|
* Kuzzle will throw a PreconditionError if a dump is already running
|
|
@@ -45,7 +51,7 @@ declare class AdminController extends NativeController {
|
|
|
45
51
|
loadSecurities(request: KuzzleRequest): Promise<{
|
|
46
52
|
acknowledge: boolean;
|
|
47
53
|
}>;
|
|
48
|
-
_waitForAction(waitForRefresh: string, promise: Promise<
|
|
54
|
+
_waitForAction(waitForRefresh: string, promise: Promise<unknown>): Promise<{
|
|
49
55
|
acknowledge: boolean;
|
|
50
56
|
}>;
|
|
51
57
|
}
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
@@ -48,7 +58,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
48
58
|
const bluebird_1 = __importDefault(require("bluebird"));
|
|
49
59
|
const kerror = __importStar(require("../../kerror"));
|
|
50
60
|
const baseController_1 = require("./baseController");
|
|
51
|
-
const
|
|
61
|
+
const distributedLock_1 = require("../../util/distributedLock");
|
|
52
62
|
/**
|
|
53
63
|
* @class AdminController
|
|
54
64
|
*/
|
|
@@ -92,40 +102,46 @@ class AdminController extends baseController_1.NativeController {
|
|
|
92
102
|
* Reset all roles, profiles and users
|
|
93
103
|
*/
|
|
94
104
|
async resetSecurity() {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
throw kerror.get("api", "process", "action_locked", "Kuzzle is already reseting roles, profiles and users.");
|
|
98
|
-
}
|
|
99
|
-
const result = {};
|
|
100
|
-
try {
|
|
105
|
+
return this.failIfLocked("resetSecurity", "Kuzzle is already reseting roles, profiles and users.", async () => {
|
|
106
|
+
const result = {};
|
|
101
107
|
const options = { refresh: "wait_for" };
|
|
102
108
|
result.deletedUsers = await this.ask("core:security:user:truncate", options);
|
|
103
109
|
result.deletedProfiles = await this.ask("core:security:profile:truncate", options);
|
|
104
110
|
result.deletedRoles = await this.ask("core:security:role:truncate", options);
|
|
105
111
|
await global.kuzzle.internalIndex.createInitialSecurities();
|
|
106
112
|
await this.ask("core:cache:internal:del", `backend:init:import:permissions`);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
await mutex.unlock();
|
|
110
|
-
}
|
|
111
|
-
return result;
|
|
113
|
+
return result;
|
|
114
|
+
});
|
|
112
115
|
}
|
|
113
116
|
/**
|
|
114
117
|
* Reset all indexes created by users
|
|
115
118
|
*/
|
|
116
119
|
async resetDatabase() {
|
|
117
|
-
|
|
118
|
-
if (!(await mutex.lock())) {
|
|
119
|
-
throw kerror.get("api", "process", "action_locked", "Kuzzle is already reseting all indexes.");
|
|
120
|
-
}
|
|
121
|
-
try {
|
|
120
|
+
return this.failIfLocked("resetDatabase", "Kuzzle is already reseting all indexes.", async () => {
|
|
122
121
|
const indexes = await this.ask("core:storage:public:index:list");
|
|
123
122
|
await this.ask("core:storage:public:index:mDelete", indexes);
|
|
124
123
|
await this.ask("core:cache:internal:del", `backend:init:import:mappings`);
|
|
125
124
|
return { acknowledge: true };
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Runs `callback` under the `resource` lock, or refuses the action right
|
|
129
|
+
* away if another node or request already holds it
|
|
130
|
+
*/
|
|
131
|
+
async failIfLocked(resource, message, callback) {
|
|
132
|
+
let acquired = false;
|
|
133
|
+
try {
|
|
134
|
+
return await (0, distributedLock_1.withLock)(resource, async () => {
|
|
135
|
+
acquired = true;
|
|
136
|
+
return callback();
|
|
137
|
+
}, { retryAttempts: 0 });
|
|
126
138
|
}
|
|
127
|
-
|
|
128
|
-
|
|
139
|
+
catch (error) {
|
|
140
|
+
// The same error thrown from inside the callback is not this lock
|
|
141
|
+
if (!acquired && error instanceof distributedLock_1.MutexAcquireError) {
|
|
142
|
+
throw kerror.get("api", "process", "action_locked", message);
|
|
143
|
+
}
|
|
144
|
+
throw error;
|
|
129
145
|
}
|
|
130
146
|
}
|
|
131
147
|
/**
|
|
@@ -4,6 +4,16 @@ import { NativeController } from "./baseController";
|
|
|
4
4
|
import { User } from "../../model/security/user";
|
|
5
5
|
import type { JSONObject } from "../../types/JSONObject";
|
|
6
6
|
import type { Token } from "../../model/security/token";
|
|
7
|
+
/**
|
|
8
|
+
* The token as the API answers it. Cookie authentication keeps `jwt` out of
|
|
9
|
+
* the body.
|
|
10
|
+
*/
|
|
11
|
+
type SentToken = {
|
|
12
|
+
_id: Token["userId"];
|
|
13
|
+
expiresAt: Token["expiresAt"];
|
|
14
|
+
jwt?: Token["jwt"];
|
|
15
|
+
ttl: Token["ttl"];
|
|
16
|
+
};
|
|
7
17
|
declare class AuthController extends NativeController {
|
|
8
18
|
private anonymousId;
|
|
9
19
|
private readonly logger;
|
|
@@ -18,7 +28,7 @@ declare class AuthController extends NativeController {
|
|
|
18
28
|
*
|
|
19
29
|
* @returns {Promise}
|
|
20
30
|
*/
|
|
21
|
-
init(): Promise<
|
|
31
|
+
init(): Promise<void>;
|
|
22
32
|
/**
|
|
23
33
|
* The user and the token the funnel attached to the request.
|
|
24
34
|
*
|
|
@@ -73,7 +83,7 @@ declare class AuthController extends NativeController {
|
|
|
73
83
|
* @returns {Promise<object>}
|
|
74
84
|
*/
|
|
75
85
|
logout(request: KuzzleRequest): Promise<object>;
|
|
76
|
-
_sendToken(token: Token, request: KuzzleRequest):
|
|
86
|
+
_sendToken(token: Token, request: KuzzleRequest): SentToken;
|
|
77
87
|
/**
|
|
78
88
|
* Attempts a login with request informations against the provided strategy;
|
|
79
89
|
* local is used if strategy is not provided.
|
|
@@ -81,7 +91,7 @@ declare class AuthController extends NativeController {
|
|
|
81
91
|
* @param {KuzzleRequest} request
|
|
82
92
|
* @returns {Promise<Token>}
|
|
83
93
|
*/
|
|
84
|
-
login(request: KuzzleRequest): Promise<
|
|
94
|
+
login(request: KuzzleRequest): Promise<unknown>;
|
|
85
95
|
/**
|
|
86
96
|
* Returns the user identified by the given jwt token
|
|
87
97
|
*
|
|
@@ -119,7 +129,7 @@ declare class AuthController extends NativeController {
|
|
|
119
129
|
* @param {KuzzleRequest} request
|
|
120
130
|
* @returns {Promise<object>}
|
|
121
131
|
*/
|
|
122
|
-
updateSelf(request: KuzzleRequest): Promise<import("../../types/core/auth/
|
|
132
|
+
updateSelf(request: KuzzleRequest): Promise<import("../../types/core/auth/Serialized").Serialized<User>>;
|
|
123
133
|
/**
|
|
124
134
|
* List authentication strategies
|
|
125
135
|
*
|
|
@@ -161,7 +171,7 @@ declare class AuthController extends NativeController {
|
|
|
161
171
|
/**
|
|
162
172
|
* @param {KuzzleRequest} request
|
|
163
173
|
*/
|
|
164
|
-
refreshToken(request: KuzzleRequest): Promise<
|
|
174
|
+
refreshToken(request: KuzzleRequest): Promise<SentToken>;
|
|
165
175
|
assertIsAuthenticated(request: KuzzleRequest): void;
|
|
166
176
|
}
|
|
167
177
|
export = AuthController;
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
@@ -48,7 +58,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
48
58
|
const node_http_1 = require("node:http");
|
|
49
59
|
const node_net_1 = require("node:net");
|
|
50
60
|
const node_util_1 = require("node:util");
|
|
51
|
-
const
|
|
61
|
+
const cookie_1 = require("cookie");
|
|
52
62
|
const bluebird_1 = __importDefault(require("bluebird"));
|
|
53
63
|
const lodash_1 = require("lodash");
|
|
54
64
|
const errors_1 = require("../../kerror/errors");
|
|
@@ -243,12 +253,14 @@ class AuthController extends baseController_1.NativeController {
|
|
|
243
253
|
request.getBoolean("cookieAuth")) {
|
|
244
254
|
request.response.configure({
|
|
245
255
|
headers: {
|
|
246
|
-
// The empty string, not `null`:
|
|
256
|
+
// The empty string, not `null`: the cookie library stringifies its
|
|
247
257
|
// value, so this header used to read `authToken=null`.
|
|
248
|
-
"Set-Cookie":
|
|
258
|
+
"Set-Cookie": (0, cookie_1.stringifySetCookie)({
|
|
249
259
|
httpOnly: true,
|
|
260
|
+
name: "authToken",
|
|
250
261
|
path: "/",
|
|
251
262
|
sameSite: "strict",
|
|
263
|
+
value: "",
|
|
252
264
|
}),
|
|
253
265
|
},
|
|
254
266
|
});
|
|
@@ -256,7 +268,7 @@ class AuthController extends baseController_1.NativeController {
|
|
|
256
268
|
return { acknowledged: true };
|
|
257
269
|
}
|
|
258
270
|
// Used to send the Token using different ways when in cookieAuth mode. (DRY)
|
|
259
|
-
|
|
271
|
+
_sendToken(token, request) {
|
|
260
272
|
const tokenResponse = {
|
|
261
273
|
_id: token.userId,
|
|
262
274
|
expiresAt: token.expiresAt,
|
|
@@ -281,11 +293,13 @@ class AuthController extends baseController_1.NativeController {
|
|
|
281
293
|
}
|
|
282
294
|
request.response.configure({
|
|
283
295
|
headers: {
|
|
284
|
-
"Set-Cookie":
|
|
296
|
+
"Set-Cookie": (0, cookie_1.stringifySetCookie)({
|
|
285
297
|
expires: new Date(token.expiresAt),
|
|
286
298
|
httpOnly: true,
|
|
299
|
+
name: "authToken",
|
|
287
300
|
path: "/",
|
|
288
301
|
sameSite: "strict",
|
|
302
|
+
value: token.jwt,
|
|
289
303
|
}),
|
|
290
304
|
},
|
|
291
305
|
});
|
|
@@ -305,7 +319,11 @@ class AuthController extends baseController_1.NativeController {
|
|
|
305
319
|
// An unconnected socket rather than `null`: `IncomingMessage` only reads
|
|
306
320
|
// `readableHighWaterMark` off it, `net.Socket` opens no descriptor until
|
|
307
321
|
// it is connected, and the parameter is not optional.
|
|
308
|
-
const passportRequest = new node_http_1.IncomingMessage(new node_net_1.Socket())
|
|
322
|
+
const passportRequest = Object.assign(new node_http_1.IncomingMessage(new node_net_1.Socket()), {
|
|
323
|
+
body: request.input.body,
|
|
324
|
+
original: request,
|
|
325
|
+
query: request.input.args,
|
|
326
|
+
});
|
|
309
327
|
// Even in http, the url and the method are not pushed back to the request object
|
|
310
328
|
// set some arbitrary values to get a pseudo-valid object.
|
|
311
329
|
passportRequest.url = `/login?strategy=${strategy}`;
|
|
@@ -313,14 +331,11 @@ class AuthController extends baseController_1.NativeController {
|
|
|
313
331
|
passportRequest.httpVersion = "1.1";
|
|
314
332
|
passportRequest.httpVersionMajor = 1;
|
|
315
333
|
passportRequest.httpVersionMinor = 1;
|
|
316
|
-
|
|
317
|
-
passportRequest.
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
passportRequest.rawHeaders.push(h);
|
|
321
|
-
passportRequest.rawHeaders.push(passportRequest.headers[h]);
|
|
334
|
+
const headers = { ...request.input.headers };
|
|
335
|
+
passportRequest.headers = headers;
|
|
336
|
+
for (const h of Object.keys(headers)) {
|
|
337
|
+
passportRequest.rawHeaders.push(h, headers[h]);
|
|
322
338
|
}
|
|
323
|
-
passportRequest.original = request;
|
|
324
339
|
if (!(0, safeObject_1.has)(globalThis.kuzzle.pluginsManager.strategies, strategy)) {
|
|
325
340
|
throw kerror.get("security", "credentials", "unknown_strategy", strategy);
|
|
326
341
|
}
|
|
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
35
35
|
}) : function(o, v) {
|
|
36
36
|
o["default"] = v;
|
|
37
37
|
});
|
|
38
|
-
var __importStar = (this && this.__importStar) || function (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
38
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
39
|
+
var ownKeys = function(o) {
|
|
40
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
41
|
+
var ar = [];
|
|
42
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
43
|
+
return ar;
|
|
44
|
+
};
|
|
45
|
+
return ownKeys(o);
|
|
46
|
+
};
|
|
47
|
+
return function (mod) {
|
|
48
|
+
if (mod && mod.__esModule) return mod;
|
|
49
|
+
var result = {};
|
|
50
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
51
|
+
__setModuleDefault(result, mod);
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
54
|
+
})();
|
|
45
55
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
56
|
exports.NativeController = exports.BaseController = void 0;
|
|
47
57
|
const kerror = __importStar(require("../../kerror"));
|
|
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
35
35
|
}) : function(o, v) {
|
|
36
36
|
o["default"] = v;
|
|
37
37
|
});
|
|
38
|
-
var __importStar = (this && this.__importStar) || function (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
38
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
39
|
+
var ownKeys = function(o) {
|
|
40
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
41
|
+
var ar = [];
|
|
42
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
43
|
+
return ar;
|
|
44
|
+
};
|
|
45
|
+
return ownKeys(o);
|
|
46
|
+
};
|
|
47
|
+
return function (mod) {
|
|
48
|
+
if (mod && mod.__esModule) return mod;
|
|
49
|
+
var result = {};
|
|
50
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
51
|
+
__setModuleDefault(result, mod);
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
54
|
+
})();
|
|
45
55
|
const actionEnum = __importStar(require("../../core/realtime/actionEnum"));
|
|
46
56
|
const kerror = __importStar(require("../../kerror"));
|
|
47
57
|
const baseController_1 = require("./baseController");
|
|
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
35
35
|
}) : function(o, v) {
|
|
36
36
|
o["default"] = v;
|
|
37
37
|
});
|
|
38
|
-
var __importStar = (this && this.__importStar) || function (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
38
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
39
|
+
var ownKeys = function(o) {
|
|
40
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
41
|
+
var ar = [];
|
|
42
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
43
|
+
return ar;
|
|
44
|
+
};
|
|
45
|
+
return ownKeys(o);
|
|
46
|
+
};
|
|
47
|
+
return function (mod) {
|
|
48
|
+
if (mod && mod.__esModule) return mod;
|
|
49
|
+
var result = {};
|
|
50
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
51
|
+
__setModuleDefault(result, mod);
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
54
|
+
})();
|
|
45
55
|
const kerror = __importStar(require("../../kerror"));
|
|
46
56
|
const errors_1 = require("../../kerror/errors");
|
|
47
57
|
const safeObject_1 = require("../../util/safeObject");
|
|
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
35
35
|
}) : function(o, v) {
|
|
36
36
|
o["default"] = v;
|
|
37
37
|
});
|
|
38
|
-
var __importStar = (this && this.__importStar) || function (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
38
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
39
|
+
var ownKeys = function(o) {
|
|
40
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
41
|
+
var ar = [];
|
|
42
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
43
|
+
return ar;
|
|
44
|
+
};
|
|
45
|
+
return ownKeys(o);
|
|
46
|
+
};
|
|
47
|
+
return function (mod) {
|
|
48
|
+
if (mod && mod.__esModule) return mod;
|
|
49
|
+
var result = {};
|
|
50
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
51
|
+
__setModuleDefault(result, mod);
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
54
|
+
})();
|
|
45
55
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
46
56
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
47
57
|
};
|
|
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
35
35
|
}) : function(o, v) {
|
|
36
36
|
o["default"] = v;
|
|
37
37
|
});
|
|
38
|
-
var __importStar = (this && this.__importStar) || function (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
38
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
39
|
+
var ownKeys = function(o) {
|
|
40
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
41
|
+
var ar = [];
|
|
42
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
43
|
+
return ar;
|
|
44
|
+
};
|
|
45
|
+
return ownKeys(o);
|
|
46
|
+
};
|
|
47
|
+
return function (mod) {
|
|
48
|
+
if (mod && mod.__esModule) return mod;
|
|
49
|
+
var result = {};
|
|
50
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
51
|
+
__setModuleDefault(result, mod);
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
54
|
+
})();
|
|
45
55
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
46
56
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
47
57
|
};
|
|
@@ -35,13 +35,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
35
35
|
}) : function(o, v) {
|
|
36
36
|
o["default"] = v;
|
|
37
37
|
});
|
|
38
|
-
var __importStar = (this && this.__importStar) || function (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
38
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
39
|
+
var ownKeys = function(o) {
|
|
40
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
41
|
+
var ar = [];
|
|
42
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
43
|
+
return ar;
|
|
44
|
+
};
|
|
45
|
+
return ownKeys(o);
|
|
46
|
+
};
|
|
47
|
+
return function (mod) {
|
|
48
|
+
if (mod && mod.__esModule) return mod;
|
|
49
|
+
var result = {};
|
|
50
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
51
|
+
__setModuleDefault(result, mod);
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
54
|
+
})();
|
|
45
55
|
const kerror_1 = require("../../kerror");
|
|
46
56
|
const request_1 = require("../request");
|
|
47
57
|
const baseController_1 = require("./baseController");
|