@futdevpro/nts-dynamo 1.15.49 โ 1.15.52
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/.dynamo/logs/cicd-pipeline/output.log +1580 -1554
- package/.dynamo/logs/cicd-pipeline/status.json +189 -189
- package/.dynamo/pipeline.cicd.config.json +12 -4
- package/build/_modules/server/server-status/server-status.controller.d.ts +60 -0
- package/build/_modules/server/server-status/server-status.controller.d.ts.map +1 -1
- package/build/_modules/server/server-status/server-status.controller.js +68 -0
- package/build/_modules/server/server-status/server-status.controller.js.map +1 -1
- package/package.json +2 -2
- package/pnpm-workspace.yaml +1 -5
- package/src/_modules/server/server-status/server-status.controller.spec.ts +77 -0
- package/src/_modules/server/server-status/server-status.controller.ts +104 -5
|
@@ -39,7 +39,10 @@
|
|
|
39
39
|
"fatal": true,
|
|
40
40
|
"discord": {
|
|
41
41
|
"emoji": "๐",
|
|
42
|
-
"name": "Pre-flight Check"
|
|
42
|
+
"name": "Pre-flight Check",
|
|
43
|
+
"group": "preflight",
|
|
44
|
+
"groupName": "Pre-flight Check",
|
|
45
|
+
"groupEmoji": "๐"
|
|
43
46
|
},
|
|
44
47
|
"settings": {
|
|
45
48
|
"requiredEnvVars": [
|
|
@@ -61,7 +64,8 @@
|
|
|
61
64
|
"fatal": false,
|
|
62
65
|
"discord": {
|
|
63
66
|
"emoji": "๐",
|
|
64
|
-
"name": "Dev Leftovers Check"
|
|
67
|
+
"name": "Dev Leftovers Check",
|
|
68
|
+
"group": "preflight"
|
|
65
69
|
},
|
|
66
70
|
"settings": {
|
|
67
71
|
"checks": [
|
|
@@ -87,7 +91,10 @@
|
|
|
87
91
|
"fatal": true,
|
|
88
92
|
"discord": {
|
|
89
93
|
"emoji": "๐๏ธ",
|
|
90
|
-
"name": "Build"
|
|
94
|
+
"name": "Build",
|
|
95
|
+
"group": "build-test",
|
|
96
|
+
"groupName": "Build and Test",
|
|
97
|
+
"groupEmoji": "๐๏ธ"
|
|
91
98
|
}
|
|
92
99
|
},
|
|
93
100
|
{
|
|
@@ -96,7 +103,8 @@
|
|
|
96
103
|
"fatal": true,
|
|
97
104
|
"discord": {
|
|
98
105
|
"emoji": "๐งช",
|
|
99
|
-
"name": "Tests"
|
|
106
|
+
"name": "Tests",
|
|
107
|
+
"group": "build-test"
|
|
100
108
|
}
|
|
101
109
|
},
|
|
102
110
|
{
|
|
@@ -1,9 +1,36 @@
|
|
|
1
|
+
import { Request, Response } from 'express';
|
|
1
2
|
import { DyFM_Error, DyFM_Errors, DyFM_ServerStatus } from '@futdevpro/fsm-dynamo';
|
|
2
3
|
import { DyNTS_Errors_ControlService } from '../errors/errors.control-service';
|
|
3
4
|
import { DyNTS_Controller } from '../../../_services/route/controller.service';
|
|
4
5
|
import { DyNTS_Endpoint_Params } from '../../../_models/control-models/endpoint-params.control-model';
|
|
5
6
|
import { DyNTS_ServerStatus_ControlService } from './server-status.control-service';
|
|
6
7
|
import { DyNTS_ServerStatusSnapshot_ControlService } from './server-status-snapshot.control-service';
|
|
8
|
+
/**
|
|
9
|
+
* Auth retrofit config a `DyNTS_ServerStatus_Controller`-hez. Opt-in โ ha az
|
|
10
|
+
* `authPreProcess` nincs megadva, a controller a regi (auth nelkuli) viselkedest
|
|
11
|
+
* tartja. Ugyanaz a mintazat, mint a `DyNTS_Errors_Controller`-ben, DE biztonsagosabb
|
|
12
|
+
* default-tal: a liveness/readiness/client-version **probak SOHA nem gate-eltek**
|
|
13
|
+
* (orchestrator/LB auth nelkul hivja oket), es a default `protectedEndpoints` csak az
|
|
14
|
+
* admin-adat vegpontokat fedi (NEM a probakat).
|
|
15
|
+
*
|
|
16
|
+
* **Subclass-szintu konfiguracio:** az `authConfig` static, igy az abstract osztaly
|
|
17
|
+
* minden subclass-a kozott OSZTOTT (TypeScript a static field-eket per-class hatarozza meg).
|
|
18
|
+
*/
|
|
19
|
+
export interface DyNTS_ServerStatusController_AuthConfig {
|
|
20
|
+
/**
|
|
21
|
+
* Pre-process fuggveny ami minden vedett endpoint elott fut. Ha hianyzik vagy
|
|
22
|
+
* `undefined`, a controller NEM ad hozza auth-ot semelyik endpoint-hoz (regi
|
|
23
|
+
* viselkedes, opt-in safety).
|
|
24
|
+
*/
|
|
25
|
+
authPreProcess?: (req: Request, res: Response) => Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Vedett endpoint nevek listaja. Ha hianyzik, a default = csak az admin-adat
|
|
28
|
+
* vegpontok (`getServerStatus`, `getErrorStatistics`) โ a probak NEM. A
|
|
29
|
+
* `PUBLIC_PROBE_ENDPOINTS` (`getServerHealth`/`getServerReadiness`/
|
|
30
|
+
* `getServerStatusForClient`) MEG explicit listazva sem gate-elheto.
|
|
31
|
+
*/
|
|
32
|
+
protectedEndpoints?: string[];
|
|
33
|
+
}
|
|
7
34
|
/**
|
|
8
35
|
* Endpoints:
|
|
9
36
|
*
|
|
@@ -20,6 +47,39 @@ import { DyNTS_ServerStatusSnapshot_ControlService } from './server-status-snaps
|
|
|
20
47
|
export declare abstract class DyNTS_ServerStatus_Controller<T_ServerStatus extends DyFM_ServerStatus, T_Error extends DyFM_Error, T_Errors extends DyFM_Errors<T_Error>, T_Errors_ControlService extends DyNTS_Errors_ControlService<T_Error, T_Errors>, T_ServerStatusSnapshot extends DyFM_ServerStatus, T_ServerStatusSnapshot_ControlService extends DyNTS_ServerStatusSnapshot_ControlService<T_ServerStatusSnapshot>, T_ServerStatus_ControlService extends DyNTS_ServerStatus_ControlService<T_ServerStatus, T_Error, T_Errors, T_Errors_ControlService, T_ServerStatusSnapshot, T_ServerStatusSnapshot_ControlService>> extends DyNTS_Controller {
|
|
21
48
|
protected abstract readonly server_CS: T_ServerStatus_ControlService;
|
|
22
49
|
protected readonly additionalEndpoints: DyNTS_Endpoint_Params[];
|
|
50
|
+
/**
|
|
51
|
+
* Static auth config โ opt-in retrofit. Default ures objektum โ NO auth
|
|
52
|
+
* (a meglevo integraciok valtoznatlan viselkedessel folytatodnak).
|
|
53
|
+
*/
|
|
54
|
+
protected static authConfig: DyNTS_ServerStatusController_AuthConfig;
|
|
55
|
+
/**
|
|
56
|
+
* Static config setter. Hivhato a szerver startup-jan az endpoint registration ELOTT.
|
|
57
|
+
*
|
|
58
|
+
* Use case (host app):
|
|
59
|
+
* ```ts
|
|
60
|
+
* ServerStatus_Controller.configure({
|
|
61
|
+
* authPreProcess: async (req, res) => auth.authenticate_tokenAndPermission(req, res, FDP_Permission.X),
|
|
62
|
+
* });
|
|
63
|
+
* ```
|
|
64
|
+
* A probak (`getServerHealth`/`getServerReadiness`/`getServerStatusForClient`) ettol
|
|
65
|
+
* fuggetlenul NYITVA maradnak.
|
|
66
|
+
*/
|
|
67
|
+
static configure(config: DyNTS_ServerStatusController_AuthConfig): void;
|
|
68
|
+
/**
|
|
69
|
+
* Aktualis auth config olvasasa (test/diagnosztika celokra).
|
|
70
|
+
*/
|
|
71
|
+
static getAuthConfig(): DyNTS_ServerStatusController_AuthConfig;
|
|
72
|
+
/**
|
|
73
|
+
* Test-only: visszaallitja az auth config-ot ures objektumra. Production code NE hivja.
|
|
74
|
+
*/
|
|
75
|
+
static _resetAuthConfigForTesting(): void;
|
|
76
|
+
/**
|
|
77
|
+
* Vissza-adja az adott endpoint-hoz tartozo `preProcesses` array-t.
|
|
78
|
+
* - Ha az auth NINCS configurolva โ ures (regi viselkedes).
|
|
79
|
+
* - A public probak SOHA nem gate-eltek.
|
|
80
|
+
* - Egyebkent az endpoint a `protectedEndpoints` (default = admin-only) listan van-e.
|
|
81
|
+
*/
|
|
82
|
+
protected getPreProcessesFor(endpointName: string): ((req: Request, res: Response) => Promise<void>)[];
|
|
23
83
|
setupEndpoints(): void;
|
|
24
84
|
}
|
|
25
85
|
//# sourceMappingURL=server-status.controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-status.controller.d.ts","sourceRoot":"","sources":["../../../../src/_modules/server/server-status/server-status.controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server-status.controller.d.ts","sourceRoot":"","sources":["../../../../src/_modules/server/server-status/server-status.controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAwC,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACzH,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+DAA+D,CAAC;AAEtG,OAAO,EAAqB,iCAAiC,EAAE,MAAM,iCAAiC,CAAC;AACvG,OAAO,EAAE,yCAAyC,EAAE,MAAM,0CAA0C,CAAC;AAGrG;;;;;;;;;;GAUG;AACH,MAAM,WAAW,uCAAuC;IACtD;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhE;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B;AAkBD;;;;;;;;;;;;GAYG;AACH,8BAAsB,6BAA6B,CACjD,cAAc,SAAS,iBAAiB,EACxC,OAAO,SAAS,UAAU,EAC1B,QAAQ,SAAS,WAAW,CAAC,OAAO,CAAC,EACrC,uBAAuB,SAAS,2BAA2B,CAAC,OAAO,EAAE,QAAQ,CAAC,EAC9E,sBAAsB,SAAS,iBAAiB,EAChD,qCAAqC,SAAS,yCAAyC,CAAC,sBAAsB,CAAC,EAC/G,6BAA6B,SAAS,iCAAiC,CACrE,cAAc,EACd,OAAO,EACP,QAAQ,EACR,uBAAuB,EACvB,sBAAsB,EACtB,qCAAqC,CACtC,CACD,SAAQ,gBAAgB;IAMxB,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,EAAE,6BAA6B,CAAC;IAGrE,SAAS,CAAC,QAAQ,CAAC,mBAAmB,EAAE,qBAAqB,EAAE,CAAM;IAErE;;;OAGG;IACH,SAAS,CAAC,MAAM,CAAC,UAAU,EAAE,uCAAuC,CAAM;IAE1E;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,uCAAuC,GAAG,IAAI;IAIvE;;OAEG;IACH,MAAM,CAAC,aAAa,IAAI,uCAAuC;IAI/D;;OAEG;IACH,MAAM,CAAC,0BAA0B,IAAI,IAAI;IAIzC;;;;;OAKG;IACH,SAAS,CAAC,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE;IAQtG,cAAc,IAAI,IAAI;CAkGvB"}
|
|
@@ -5,6 +5,20 @@ const fsm_dynamo_1 = require("@futdevpro/fsm-dynamo");
|
|
|
5
5
|
const controller_service_1 = require("../../../_services/route/controller.service");
|
|
6
6
|
const endpoint_params_control_model_1 = require("../../../_models/control-models/endpoint-params.control-model");
|
|
7
7
|
const global_settings_const_1 = require("../../../_collections/global-settings.const");
|
|
8
|
+
/**
|
|
9
|
+
* Public probak โ orchestrator/LB hivja auth nelkul, ezert SOHA nem gate-eljuk
|
|
10
|
+
* (meg ha a host explicit listazza is a `protectedEndpoints`-ban).
|
|
11
|
+
*/
|
|
12
|
+
const PUBLIC_PROBE_ENDPOINTS = [
|
|
13
|
+
'getServerHealth', 'getServerReadiness', 'getServerStatusForClient',
|
|
14
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* Default vedett vegpontok (ha a host nem ad `protectedEndpoints`-t): csak az
|
|
17
|
+
* admin-adat vegpontok.
|
|
18
|
+
*/
|
|
19
|
+
const DEFAULT_PROTECTED_ENDPOINTS = [
|
|
20
|
+
'getServerStatus', 'getErrorStatistics',
|
|
21
|
+
];
|
|
8
22
|
/**
|
|
9
23
|
* Endpoints:
|
|
10
24
|
*
|
|
@@ -21,6 +35,55 @@ const global_settings_const_1 = require("../../../_collections/global-settings.c
|
|
|
21
35
|
class DyNTS_ServerStatus_Controller extends controller_service_1.DyNTS_Controller {
|
|
22
36
|
/* protected abstract getServerService(): T_ServerStatusService; */
|
|
23
37
|
additionalEndpoints = [];
|
|
38
|
+
/**
|
|
39
|
+
* Static auth config โ opt-in retrofit. Default ures objektum โ NO auth
|
|
40
|
+
* (a meglevo integraciok valtoznatlan viselkedessel folytatodnak).
|
|
41
|
+
*/
|
|
42
|
+
static authConfig = {};
|
|
43
|
+
/**
|
|
44
|
+
* Static config setter. Hivhato a szerver startup-jan az endpoint registration ELOTT.
|
|
45
|
+
*
|
|
46
|
+
* Use case (host app):
|
|
47
|
+
* ```ts
|
|
48
|
+
* ServerStatus_Controller.configure({
|
|
49
|
+
* authPreProcess: async (req, res) => auth.authenticate_tokenAndPermission(req, res, FDP_Permission.X),
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
* A probak (`getServerHealth`/`getServerReadiness`/`getServerStatusForClient`) ettol
|
|
53
|
+
* fuggetlenul NYITVA maradnak.
|
|
54
|
+
*/
|
|
55
|
+
static configure(config) {
|
|
56
|
+
DyNTS_ServerStatus_Controller.authConfig = config;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Aktualis auth config olvasasa (test/diagnosztika celokra).
|
|
60
|
+
*/
|
|
61
|
+
static getAuthConfig() {
|
|
62
|
+
return DyNTS_ServerStatus_Controller.authConfig;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Test-only: visszaallitja az auth config-ot ures objektumra. Production code NE hivja.
|
|
66
|
+
*/
|
|
67
|
+
static _resetAuthConfigForTesting() {
|
|
68
|
+
DyNTS_ServerStatus_Controller.authConfig = {};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Vissza-adja az adott endpoint-hoz tartozo `preProcesses` array-t.
|
|
72
|
+
* - Ha az auth NINCS configurolva โ ures (regi viselkedes).
|
|
73
|
+
* - A public probak SOHA nem gate-eltek.
|
|
74
|
+
* - Egyebkent az endpoint a `protectedEndpoints` (default = admin-only) listan van-e.
|
|
75
|
+
*/
|
|
76
|
+
getPreProcessesFor(endpointName) {
|
|
77
|
+
const cfg = DyNTS_ServerStatus_Controller.authConfig;
|
|
78
|
+
if (!cfg.authPreProcess) {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
if (PUBLIC_PROBE_ENDPOINTS.includes(endpointName)) {
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
const protectedNames = cfg.protectedEndpoints ?? DEFAULT_PROTECTED_ENDPOINTS;
|
|
85
|
+
return protectedNames.includes(endpointName) ? [cfg.authPreProcess] : [];
|
|
86
|
+
}
|
|
24
87
|
setupEndpoints() {
|
|
25
88
|
/* if (!this.getServerService) {
|
|
26
89
|
throw new DyFM_Error({
|
|
@@ -40,6 +103,7 @@ class DyNTS_ServerStatus_Controller extends controller_service_1.DyNTS_Controlle
|
|
|
40
103
|
name: 'getServerStatus',
|
|
41
104
|
type: fsm_dynamo_1.DyFM_HttpCallType.get,
|
|
42
105
|
endpoint: '/status',
|
|
106
|
+
preProcesses: this.getPreProcessesFor('getServerStatus'),
|
|
43
107
|
tasks: [
|
|
44
108
|
async (req, res, issuer) => {
|
|
45
109
|
res.send(await this.server_CS.getServerStatus(issuer));
|
|
@@ -50,6 +114,7 @@ class DyNTS_ServerStatus_Controller extends controller_service_1.DyNTS_Controlle
|
|
|
50
114
|
name: 'getServerHealth',
|
|
51
115
|
type: fsm_dynamo_1.DyFM_HttpCallType.get,
|
|
52
116
|
endpoint: '/health',
|
|
117
|
+
preProcesses: this.getPreProcessesFor('getServerHealth'),
|
|
53
118
|
tasks: [
|
|
54
119
|
async (req, res, issuer) => {
|
|
55
120
|
res.send(await this.server_CS.getServerStatus(issuer));
|
|
@@ -62,6 +127,7 @@ class DyNTS_ServerStatus_Controller extends controller_service_1.DyNTS_Controlle
|
|
|
62
127
|
name: 'getServerReadiness',
|
|
63
128
|
type: fsm_dynamo_1.DyFM_HttpCallType.get,
|
|
64
129
|
endpoint: '/readiness',
|
|
130
|
+
preProcesses: this.getPreProcessesFor('getServerReadiness'),
|
|
65
131
|
tasks: [
|
|
66
132
|
async (req, res, issuer) => {
|
|
67
133
|
const readiness = await this.server_CS.checkDbReadiness();
|
|
@@ -73,6 +139,7 @@ class DyNTS_ServerStatus_Controller extends controller_service_1.DyNTS_Controlle
|
|
|
73
139
|
name: 'getServerStatusForClient',
|
|
74
140
|
type: fsm_dynamo_1.DyFM_HttpCallType.get,
|
|
75
141
|
endpoint: '/status/:version',
|
|
142
|
+
preProcesses: this.getPreProcessesFor('getServerStatusForClient'),
|
|
76
143
|
tasks: [
|
|
77
144
|
async (req, res, issuer) => {
|
|
78
145
|
res.send(await this.server_CS.getServerStatus(issuer, req.params.version));
|
|
@@ -83,6 +150,7 @@ class DyNTS_ServerStatus_Controller extends controller_service_1.DyNTS_Controlle
|
|
|
83
150
|
name: 'getErrorStatistics',
|
|
84
151
|
type: fsm_dynamo_1.DyFM_HttpCallType.get,
|
|
85
152
|
endpoint: '/statistics/error/:range',
|
|
153
|
+
preProcesses: this.getPreProcessesFor('getErrorStatistics'),
|
|
86
154
|
tasks: [
|
|
87
155
|
async (req, res, issuer) => {
|
|
88
156
|
res.send(await this.server_CS.getErrorStatistics(req.params.range, issuer));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-status.controller.js","sourceRoot":"","sources":["../../../../src/_modules/server/server-status/server-status.controller.ts"],"names":[],"mappings":";;;AAGA,sDAAyH;AAEzH,oFAA+E;AAC/E,iHAAsG;AACtG,uFAAoF;
|
|
1
|
+
{"version":3,"file":"server-status.controller.js","sourceRoot":"","sources":["../../../../src/_modules/server/server-status/server-status.controller.ts"],"names":[],"mappings":";;;AAGA,sDAAyH;AAEzH,oFAA+E;AAC/E,iHAAsG;AACtG,uFAAoF;AAiCpF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
|
1
1
|
{
|
|
2
2
|
"name": "@futdevpro/nts-dynamo",
|
|
3
|
-
"version": "01.15.
|
|
3
|
+
"version": "01.15.52",
|
|
4
4
|
"description": "Dynamic NodeTS (NodeJS-Typescript), MongoDB Backend System Framework by Future Development Program Ltd.",
|
|
5
5
|
"DyBu_settings": {
|
|
6
6
|
"packageType": "server-package",
|
|
@@ -332,7 +332,7 @@
|
|
|
332
332
|
"ts-node": "~10.9.2"
|
|
333
333
|
},
|
|
334
334
|
"devDependencies": {
|
|
335
|
-
"@futdevpro/dynamo-eslint": "1.15.
|
|
335
|
+
"@futdevpro/dynamo-eslint": "1.15.16",
|
|
336
336
|
"@discordjs/opus": "^0.10.0",
|
|
337
337
|
"@discordjs/voice": "^0.18.0",
|
|
338
338
|
"@types/jasmine": "~4.3.5",
|
package/pnpm-workspace.yaml
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
allowBuilds:
|
|
2
2
|
'@discordjs/opus': false
|
|
3
3
|
minimumReleaseAgeExclude:
|
|
4
|
-
- '@futdevpro
|
|
5
|
-
- '@futdevpro/fsm-dynamo@1.15.18'
|
|
6
|
-
- '@futdevpro/fsm-dynamo@1.15.19'
|
|
7
|
-
- '@futdevpro/fsm-dynamo@1.15.20'
|
|
8
|
-
- '@futdevpro/fsm-dynamo@1.15.21'
|
|
4
|
+
- '@futdevpro/*'
|
|
@@ -158,5 +158,82 @@ describe('| DyNTS_ServerStatus_Controller', () => {
|
|
|
158
158
|
}).toThrow();
|
|
159
159
|
});
|
|
160
160
|
});
|
|
161
|
+
|
|
162
|
+
describe('| opt-in admin auth retrofit', (): void => {
|
|
163
|
+
afterEach((): void => {
|
|
164
|
+
DyNTS_ServerStatus_Controller._resetAuthConfigForTesting();
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
const preCount = (controller: any, name: string): number => {
|
|
168
|
+
const ep: any = controller.endpoints.find((e: any) => e.name === name);
|
|
169
|
+
return (ep?.preProcesses ?? []).length;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
it('| default: NO preProcesses on any endpoint (backwards compatible)', (): void => {
|
|
173
|
+
controller.setupEndpoints();
|
|
174
|
+
for (const ep of controller.endpoints) {
|
|
175
|
+
const pre: any = (ep as any).preProcesses;
|
|
176
|
+
expect(pre === undefined || pre.length === 0).toBe(true);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('| configure({ authPreProcess }) โ admin endpoints gated, probรกk NEM', (): void => {
|
|
181
|
+
const fakeAuth = async (): Promise<void> => { /* noop */ };
|
|
182
|
+
DyNTS_ServerStatus_Controller.configure({ authPreProcess: fakeAuth });
|
|
183
|
+
const c: any = new (TestServerStatusController as any)();
|
|
184
|
+
c.setupEndpoints();
|
|
185
|
+
|
|
186
|
+
// admin-adat โ gated
|
|
187
|
+
expect(preCount(c, 'getServerStatus')).toBe(1);
|
|
188
|
+
expect(preCount(c, 'getErrorStatistics')).toBe(1);
|
|
189
|
+
// public probรกk โ SOHA nem gated
|
|
190
|
+
expect(preCount(c, 'getServerHealth')).toBe(0);
|
|
191
|
+
expect(preCount(c, 'getServerReadiness')).toBe(0);
|
|
192
|
+
expect(preCount(c, 'getServerStatusForClient')).toBe(0);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('| a probรกkat explicit protectedEndpoints-lista SEM gate-eli', (): void => {
|
|
196
|
+
const fakeAuth = async (): Promise<void> => { /* noop */ };
|
|
197
|
+
DyNTS_ServerStatus_Controller.configure({
|
|
198
|
+
authPreProcess: fakeAuth,
|
|
199
|
+
protectedEndpoints: [ 'getServerHealth', 'getServerReadiness', 'getServerStatusForClient', 'getServerStatus' ],
|
|
200
|
+
});
|
|
201
|
+
const c: any = new (TestServerStatusController as any)();
|
|
202
|
+
c.setupEndpoints();
|
|
203
|
+
|
|
204
|
+
expect(preCount(c, 'getServerHealth')).toBe(0);
|
|
205
|
+
expect(preCount(c, 'getServerReadiness')).toBe(0);
|
|
206
|
+
expect(preCount(c, 'getServerStatusForClient')).toBe(0);
|
|
207
|
+
// a nem-proba viszont gated
|
|
208
|
+
expect(preCount(c, 'getServerStatus')).toBe(1);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it('| protectedEndpoints subset โ csak a megadott (nem-proba) neveken aktiv', (): void => {
|
|
212
|
+
const fakeAuth = async (): Promise<void> => { /* noop */ };
|
|
213
|
+
DyNTS_ServerStatus_Controller.configure({
|
|
214
|
+
authPreProcess: fakeAuth,
|
|
215
|
+
protectedEndpoints: [ 'getErrorStatistics' ],
|
|
216
|
+
});
|
|
217
|
+
const c: any = new (TestServerStatusController as any)();
|
|
218
|
+
c.setupEndpoints();
|
|
219
|
+
|
|
220
|
+
expect(preCount(c, 'getErrorStatistics')).toBe(1);
|
|
221
|
+
expect(preCount(c, 'getServerStatus')).toBe(0);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('| getAuthConfig() returns the active config', (): void => {
|
|
225
|
+
const fakeAuth = async (): Promise<void> => { /* noop */ };
|
|
226
|
+
DyNTS_ServerStatus_Controller.configure({ authPreProcess: fakeAuth, protectedEndpoints: [ 'getErrorStatistics' ] });
|
|
227
|
+
const cfg = DyNTS_ServerStatus_Controller.getAuthConfig();
|
|
228
|
+
expect(cfg.authPreProcess).toBe(fakeAuth);
|
|
229
|
+
expect(cfg.protectedEndpoints).toEqual([ 'getErrorStatistics' ]);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it('| _resetAuthConfigForTesting() clears the config', (): void => {
|
|
233
|
+
DyNTS_ServerStatus_Controller.configure({ authPreProcess: async (): Promise<void> => { /* noop */ } });
|
|
234
|
+
DyNTS_ServerStatus_Controller._resetAuthConfigForTesting();
|
|
235
|
+
expect(DyNTS_ServerStatus_Controller.getAuthConfig().authPreProcess).toBeUndefined();
|
|
236
|
+
});
|
|
237
|
+
});
|
|
161
238
|
});
|
|
162
239
|
|
|
@@ -10,18 +10,62 @@ import { DyNTS_DbReadiness, DyNTS_ServerStatus_ControlService } from './server-s
|
|
|
10
10
|
import { DyNTS_ServerStatusSnapshot_ControlService } from './server-status-snapshot.control-service';
|
|
11
11
|
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Auth retrofit config a `DyNTS_ServerStatus_Controller`-hez. Opt-in โ ha az
|
|
15
|
+
* `authPreProcess` nincs megadva, a controller a regi (auth nelkuli) viselkedest
|
|
16
|
+
* tartja. Ugyanaz a mintazat, mint a `DyNTS_Errors_Controller`-ben, DE biztonsagosabb
|
|
17
|
+
* default-tal: a liveness/readiness/client-version **probak SOHA nem gate-eltek**
|
|
18
|
+
* (orchestrator/LB auth nelkul hivja oket), es a default `protectedEndpoints` csak az
|
|
19
|
+
* admin-adat vegpontokat fedi (NEM a probakat).
|
|
20
|
+
*
|
|
21
|
+
* **Subclass-szintu konfiguracio:** az `authConfig` static, igy az abstract osztaly
|
|
22
|
+
* minden subclass-a kozott OSZTOTT (TypeScript a static field-eket per-class hatarozza meg).
|
|
23
|
+
*/
|
|
24
|
+
export interface DyNTS_ServerStatusController_AuthConfig {
|
|
25
|
+
/**
|
|
26
|
+
* Pre-process fuggveny ami minden vedett endpoint elott fut. Ha hianyzik vagy
|
|
27
|
+
* `undefined`, a controller NEM ad hozza auth-ot semelyik endpoint-hoz (regi
|
|
28
|
+
* viselkedes, opt-in safety).
|
|
29
|
+
*/
|
|
30
|
+
authPreProcess?: (req: Request, res: Response) => Promise<void>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Vedett endpoint nevek listaja. Ha hianyzik, a default = csak az admin-adat
|
|
34
|
+
* vegpontok (`getServerStatus`, `getErrorStatistics`) โ a probak NEM. A
|
|
35
|
+
* `PUBLIC_PROBE_ENDPOINTS` (`getServerHealth`/`getServerReadiness`/
|
|
36
|
+
* `getServerStatusForClient`) MEG explicit listazva sem gate-elheto.
|
|
37
|
+
*/
|
|
38
|
+
protectedEndpoints?: string[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Public probak โ orchestrator/LB hivja auth nelkul, ezert SOHA nem gate-eljuk
|
|
43
|
+
* (meg ha a host explicit listazza is a `protectedEndpoints`-ban).
|
|
44
|
+
*/
|
|
45
|
+
const PUBLIC_PROBE_ENDPOINTS: string[] = [
|
|
46
|
+
'getServerHealth', 'getServerReadiness', 'getServerStatusForClient',
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Default vedett vegpontok (ha a host nem ad `protectedEndpoints`-t): csak az
|
|
51
|
+
* admin-adat vegpontok.
|
|
52
|
+
*/
|
|
53
|
+
const DEFAULT_PROTECTED_ENDPOINTS: string[] = [
|
|
54
|
+
'getServerStatus', 'getErrorStatistics',
|
|
55
|
+
];
|
|
56
|
+
|
|
13
57
|
/**
|
|
14
58
|
* Endpoints:
|
|
15
|
-
*
|
|
59
|
+
*
|
|
16
60
|
* getServerStatus
|
|
17
61
|
* GET /status
|
|
18
|
-
*
|
|
62
|
+
*
|
|
19
63
|
* getServerStatusForClient
|
|
20
64
|
* GET /status/:version
|
|
21
|
-
*
|
|
65
|
+
*
|
|
22
66
|
* getErrorStatistics
|
|
23
67
|
* GET /statistics/error/:range
|
|
24
|
-
*
|
|
68
|
+
*
|
|
25
69
|
*/
|
|
26
70
|
export abstract class DyNTS_ServerStatus_Controller<
|
|
27
71
|
T_ServerStatus extends DyFM_ServerStatus,
|
|
@@ -45,10 +89,60 @@ export abstract class DyNTS_ServerStatus_Controller<
|
|
|
45
89
|
} */
|
|
46
90
|
|
|
47
91
|
protected abstract readonly server_CS: T_ServerStatus_ControlService;
|
|
48
|
-
|
|
92
|
+
|
|
49
93
|
/* protected abstract getServerService(): T_ServerStatusService; */
|
|
50
94
|
protected readonly additionalEndpoints: DyNTS_Endpoint_Params[] = [];
|
|
51
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Static auth config โ opt-in retrofit. Default ures objektum โ NO auth
|
|
98
|
+
* (a meglevo integraciok valtoznatlan viselkedessel folytatodnak).
|
|
99
|
+
*/
|
|
100
|
+
protected static authConfig: DyNTS_ServerStatusController_AuthConfig = {};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Static config setter. Hivhato a szerver startup-jan az endpoint registration ELOTT.
|
|
104
|
+
*
|
|
105
|
+
* Use case (host app):
|
|
106
|
+
* ```ts
|
|
107
|
+
* ServerStatus_Controller.configure({
|
|
108
|
+
* authPreProcess: async (req, res) => auth.authenticate_tokenAndPermission(req, res, FDP_Permission.X),
|
|
109
|
+
* });
|
|
110
|
+
* ```
|
|
111
|
+
* A probak (`getServerHealth`/`getServerReadiness`/`getServerStatusForClient`) ettol
|
|
112
|
+
* fuggetlenul NYITVA maradnak.
|
|
113
|
+
*/
|
|
114
|
+
static configure(config: DyNTS_ServerStatusController_AuthConfig): void {
|
|
115
|
+
DyNTS_ServerStatus_Controller.authConfig = config;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Aktualis auth config olvasasa (test/diagnosztika celokra).
|
|
120
|
+
*/
|
|
121
|
+
static getAuthConfig(): DyNTS_ServerStatusController_AuthConfig {
|
|
122
|
+
return DyNTS_ServerStatus_Controller.authConfig;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Test-only: visszaallitja az auth config-ot ures objektumra. Production code NE hivja.
|
|
127
|
+
*/
|
|
128
|
+
static _resetAuthConfigForTesting(): void {
|
|
129
|
+
DyNTS_ServerStatus_Controller.authConfig = {};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Vissza-adja az adott endpoint-hoz tartozo `preProcesses` array-t.
|
|
134
|
+
* - Ha az auth NINCS configurolva โ ures (regi viselkedes).
|
|
135
|
+
* - A public probak SOHA nem gate-eltek.
|
|
136
|
+
* - Egyebkent az endpoint a `protectedEndpoints` (default = admin-only) listan van-e.
|
|
137
|
+
*/
|
|
138
|
+
protected getPreProcessesFor(endpointName: string): ((req: Request, res: Response) => Promise<void>)[] {
|
|
139
|
+
const cfg: DyNTS_ServerStatusController_AuthConfig = DyNTS_ServerStatus_Controller.authConfig;
|
|
140
|
+
if (!cfg.authPreProcess) { return []; }
|
|
141
|
+
if (PUBLIC_PROBE_ENDPOINTS.includes(endpointName)) { return []; }
|
|
142
|
+
const protectedNames: string[] = cfg.protectedEndpoints ?? DEFAULT_PROTECTED_ENDPOINTS;
|
|
143
|
+
return protectedNames.includes(endpointName) ? [cfg.authPreProcess] : [];
|
|
144
|
+
}
|
|
145
|
+
|
|
52
146
|
setupEndpoints(): void {
|
|
53
147
|
/* if (!this.getServerService) {
|
|
54
148
|
throw new DyFM_Error({
|
|
@@ -71,6 +165,7 @@ export abstract class DyNTS_ServerStatus_Controller<
|
|
|
71
165
|
name: 'getServerStatus',
|
|
72
166
|
type: DyFM_HttpCallType.get,
|
|
73
167
|
endpoint: '/status',
|
|
168
|
+
preProcesses: this.getPreProcessesFor('getServerStatus'),
|
|
74
169
|
tasks: [
|
|
75
170
|
async (req: Request, res: Response, issuer: string): Promise<void> => {
|
|
76
171
|
res.send(
|
|
@@ -84,6 +179,7 @@ export abstract class DyNTS_ServerStatus_Controller<
|
|
|
84
179
|
name: 'getServerHealth',
|
|
85
180
|
type: DyFM_HttpCallType.get,
|
|
86
181
|
endpoint: '/health',
|
|
182
|
+
preProcesses: this.getPreProcessesFor('getServerHealth'),
|
|
87
183
|
tasks: [
|
|
88
184
|
async (req: Request, res: Response, issuer: string): Promise<void> => {
|
|
89
185
|
res.send(
|
|
@@ -99,6 +195,7 @@ export abstract class DyNTS_ServerStatus_Controller<
|
|
|
99
195
|
name: 'getServerReadiness',
|
|
100
196
|
type: DyFM_HttpCallType.get,
|
|
101
197
|
endpoint: '/readiness',
|
|
198
|
+
preProcesses: this.getPreProcessesFor('getServerReadiness'),
|
|
102
199
|
tasks: [
|
|
103
200
|
async (req: Request, res: Response, issuer: string): Promise<void> => {
|
|
104
201
|
const readiness: DyNTS_DbReadiness = await this.server_CS.checkDbReadiness();
|
|
@@ -112,6 +209,7 @@ export abstract class DyNTS_ServerStatus_Controller<
|
|
|
112
209
|
name: 'getServerStatusForClient',
|
|
113
210
|
type: DyFM_HttpCallType.get,
|
|
114
211
|
endpoint: '/status/:version',
|
|
212
|
+
preProcesses: this.getPreProcessesFor('getServerStatusForClient'),
|
|
115
213
|
tasks: [
|
|
116
214
|
async (req: Request, res: Response, issuer: string): Promise<void> => {
|
|
117
215
|
|
|
@@ -126,6 +224,7 @@ export abstract class DyNTS_ServerStatus_Controller<
|
|
|
126
224
|
name: 'getErrorStatistics',
|
|
127
225
|
type: DyFM_HttpCallType.get,
|
|
128
226
|
endpoint: '/statistics/error/:range',
|
|
227
|
+
preProcesses: this.getPreProcessesFor('getErrorStatistics'),
|
|
129
228
|
tasks: [
|
|
130
229
|
async (req: Request, res: Response, issuer: string) : Promise<void> => {
|
|
131
230
|
|