emilsoftware-utilities 2.0.0-dev.78 → 2.0.0-dev.79
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/accessi/client/generated/admin.d.ts +21 -1
- package/dist/accessi/client/generated/admin.js +35 -1
- package/dist/accessi/client/generated/admin.js.map +1 -1
- package/dist/accessi-module/AccessiModule.d.ts +3 -0
- package/dist/accessi-module/AccessiModule.js +4 -0
- package/dist/accessi-module/AccessiModule.js.map +1 -1
- package/dist/accessi-module/Console/console.js +1 -0
- package/dist/accessi-module/Console/generated/emilsoftware-utilities.d.ts +21 -1
- package/dist/accessi-module/Console/generated/emilsoftware-utilities.js +35 -1
- package/dist/accessi-module/Console/generated/emilsoftware-utilities.js.map +1 -1
- package/dist/accessi-module/Console/generated/model/exportAuditOrder.d.ts +11 -0
- package/dist/accessi-module/Console/generated/model/exportAuditOrder.js +15 -0
- package/dist/accessi-module/Console/generated/model/exportAuditOrder.js.map +1 -0
- package/dist/accessi-module/Console/generated/model/exportAuditParams.d.ts +37 -0
- package/dist/accessi-module/Console/generated/model/exportAuditParams.js +3 -0
- package/dist/accessi-module/Console/generated/model/exportAuditParams.js.map +1 -0
- package/dist/accessi-module/Console/generated/model/index.d.ts +4 -0
- package/dist/accessi-module/Console/generated/model/index.js +4 -0
- package/dist/accessi-module/Console/generated/model/index.js.map +1 -1
- package/dist/accessi-module/Console/generated/model/queryAuditOrder.d.ts +11 -0
- package/dist/accessi-module/Console/generated/model/queryAuditOrder.js +15 -0
- package/dist/accessi-module/Console/generated/model/queryAuditOrder.js.map +1 -0
- package/dist/accessi-module/Console/generated/model/queryAuditParams.d.ts +37 -0
- package/dist/accessi-module/Console/generated/model/queryAuditParams.js +3 -0
- package/dist/accessi-module/Console/generated/model/queryAuditParams.js.map +1 -0
- package/dist/accessi-module/Console/wiki.js +1 -0
- package/dist/accessi-module/Console/wiki.js.map +1 -1
- package/dist/accessi-module/Controllers/AccessiAuditController.d.ts +16 -0
- package/dist/accessi-module/Controllers/AccessiAuditController.js +155 -0
- package/dist/accessi-module/Controllers/AccessiAuditController.js.map +1 -0
- package/dist/accessi-module/Controllers/AuthController.js +15 -0
- package/dist/accessi-module/Controllers/AuthController.js.map +1 -1
- package/dist/accessi-module/Controllers/ConsoleEntryController.js +6 -0
- package/dist/accessi-module/Controllers/ConsoleEntryController.js.map +1 -1
- package/dist/accessi-module/Dtos/AuditDtos.d.ts +10 -0
- package/dist/accessi-module/Dtos/AuditDtos.js +68 -0
- package/dist/accessi-module/Dtos/AuditDtos.js.map +1 -0
- package/dist/accessi-module/Dtos/index.d.ts +1 -0
- package/dist/accessi-module/Dtos/index.js +1 -0
- package/dist/accessi-module/Dtos/index.js.map +1 -1
- package/dist/accessi-module/index.d.ts +5 -1
- package/dist/accessi-module/index.js +14 -3
- package/dist/accessi-module/index.js.map +1 -1
- package/dist/accessi-module/security/audit.d.ts +68 -3
- package/dist/accessi-module/security/audit.js +177 -4
- package/dist/accessi-module/security/audit.js.map +1 -1
- package/dist/accessi-module/security/auditSinks.d.ts +55 -0
- package/dist/accessi-module/security/auditSinks.js +228 -0
- package/dist/accessi-module/security/auditSinks.js.map +1 -0
- package/dist/accessi-module/security/jwtTokenOptions.js +2 -0
- package/dist/accessi-module/security/jwtTokenOptions.js.map +1 -1
- package/dist/accessi-module/security/publicAuthRateLimit.js +7 -0
- package/dist/accessi-module/security/publicAuthRateLimit.js.map +1 -1
- package/dist/accessi-module/security/sessionRevocation.js.map +1 -1
- package/dist/emilsoftware-utilities-2.0.0-dev.79.tgz +0 -0
- package/docs/audit.md +136 -0
- package/package.json +3 -3
- package/dist/emilsoftware-utilities-2.0.0-dev.78.tgz +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AuditQueryRequest = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_transformer_1 = require("class-transformer");
|
|
15
|
+
const class_validator_1 = require("class-validator");
|
|
16
|
+
/** Filtri degli endpoint audit per amministratori. */
|
|
17
|
+
class AuditQueryRequest {
|
|
18
|
+
}
|
|
19
|
+
exports.AuditQueryRequest = AuditQueryRequest;
|
|
20
|
+
__decorate([
|
|
21
|
+
(0, swagger_1.ApiPropertyOptional)({ description: 'Nome esatto dell evento, es. login_succeeded.' }),
|
|
22
|
+
(0, class_validator_1.IsOptional)(),
|
|
23
|
+
(0, class_validator_1.IsString)(),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], AuditQueryRequest.prototype, "event", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, swagger_1.ApiPropertyOptional)({ description: 'Inizio intervallo (ISO 8601).' }),
|
|
28
|
+
(0, class_validator_1.IsOptional)(),
|
|
29
|
+
(0, class_validator_1.IsISO8601)(),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], AuditQueryRequest.prototype, "from", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, swagger_1.ApiPropertyOptional)({ description: 'Fine intervallo (ISO 8601).' }),
|
|
34
|
+
(0, class_validator_1.IsOptional)(),
|
|
35
|
+
(0, class_validator_1.IsISO8601)(),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], AuditQueryRequest.prototype, "to", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, swagger_1.ApiPropertyOptional)({ description: 'Filtra per codice utente Accessi.' }),
|
|
40
|
+
(0, class_validator_1.IsOptional)(),
|
|
41
|
+
(0, class_transformer_1.Type)(() => Number),
|
|
42
|
+
(0, class_validator_1.IsInt)(),
|
|
43
|
+
__metadata("design:type", Number)
|
|
44
|
+
], AuditQueryRequest.prototype, "codiceUtente", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, swagger_1.ApiPropertyOptional)({ description: 'Record per pagina. Default 100, massimo 1000.' }),
|
|
47
|
+
(0, class_validator_1.IsOptional)(),
|
|
48
|
+
(0, class_transformer_1.Type)(() => Number),
|
|
49
|
+
(0, class_validator_1.IsInt)(),
|
|
50
|
+
(0, class_validator_1.Min)(1),
|
|
51
|
+
(0, class_validator_1.Max)(1000),
|
|
52
|
+
__metadata("design:type", Number)
|
|
53
|
+
], AuditQueryRequest.prototype, "limit", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, swagger_1.ApiPropertyOptional)({ description: 'Offset della pagina. Default 0.' }),
|
|
56
|
+
(0, class_validator_1.IsOptional)(),
|
|
57
|
+
(0, class_transformer_1.Type)(() => Number),
|
|
58
|
+
(0, class_validator_1.IsInt)(),
|
|
59
|
+
(0, class_validator_1.Min)(0),
|
|
60
|
+
__metadata("design:type", Number)
|
|
61
|
+
], AuditQueryRequest.prototype, "offset", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, swagger_1.ApiPropertyOptional)({ enum: ['asc', 'desc'], description: 'Ordinamento per timestamp. Default desc.' }),
|
|
64
|
+
(0, class_validator_1.IsOptional)(),
|
|
65
|
+
(0, class_validator_1.IsIn)(['asc', 'desc']),
|
|
66
|
+
__metadata("design:type", String)
|
|
67
|
+
], AuditQueryRequest.prototype, "order", void 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G,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,uBAAK,GAAE;IACP,IAAA,qBAAG,EAAC,CAAC,CAAC;;iDACS;AAKhB;IAHC,IAAA,6BAAmB,EAAC,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC;IACvG,IAAA,4BAAU,GAAE;IACZ,IAAA,sBAAI,EAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;;gDACC","sourcesContent":["import { ApiPropertyOptional } from '@nestjs/swagger';\nimport { Type } from 'class-transformer';\nimport { IsIn, IsInt, IsISO8601, IsOptional, IsString, Max, Min } from 'class-validator';\n\n/** Filtri degli endpoint audit per amministratori. */\nexport class AuditQueryRequest {\n @ApiPropertyOptional({ description: 'Nome esatto dell evento, es. login_succeeded.' })\n @IsOptional()\n @IsString()\n event?: string;\n\n @ApiPropertyOptional({ description: 'Inizio intervallo (ISO 8601).' })\n @IsOptional()\n @IsISO8601()\n from?: string;\n\n @ApiPropertyOptional({ description: 'Fine intervallo (ISO 8601).' })\n @IsOptional()\n @IsISO8601()\n to?: string;\n\n @ApiPropertyOptional({ description: 'Filtra per codice utente Accessi.' })\n @IsOptional()\n @Type(() => Number)\n @IsInt()\n codiceUtente?: number;\n\n @ApiPropertyOptional({ description: 'Record per pagina. Default 100, massimo 1000.' })\n @IsOptional()\n @Type(() => Number)\n @IsInt()\n @Min(1)\n @Max(1000)\n limit?: number;\n\n @ApiPropertyOptional({ description: 'Offset della pagina. Default 0.' })\n @IsOptional()\n @Type(() => Number)\n @IsInt()\n @Min(0)\n offset?: number;\n\n @ApiPropertyOptional({ enum: ['asc', 'desc'], description: 'Ordinamento per timestamp. Default desc.' })\n @IsOptional()\n @IsIn(['asc', 'desc'])\n order?: 'asc' | 'desc';\n}\n"]}
|
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./Abilitazione"), exports);
|
|
18
18
|
__exportStar(require("./AdminBootstrapDtos"), exports);
|
|
19
|
+
__exportStar(require("./AuditDtos"), exports);
|
|
19
20
|
__exportStar(require("./AbilitazioneMenu"), exports);
|
|
20
21
|
__exportStar(require("./AssignPermissionsToUserRequest"), exports);
|
|
21
22
|
__exportStar(require("./AssignRolesToUserRequest"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/accessi-module/Dtos/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,uDAAqC;AACrC,qDAAmC;AACnC,mEAAiD;AACjD,6DAA2C;AAC3C,gEAA8C;AAC9C,iDAA+B;AAC/B,gDAA8B;AAC9B,gEAA8C;AAC9C,+DAA4C;AAE5C,iDAA+B;AAC/B,0DAAwC;AACxC,0DAAwC;AACxC,0DAAwC;AACxC,2DAAyC;AACzC,sDAAoC;AACpC,gDAA8B;AAC9B,iDAA+B;AAC/B,kDAAgC;AAChC,+CAA6B;AAC7B,0DAAwC;AACxC,qDAAmC;AACnC,uDAAqC;AACrC,yCAAuB;AACvB,+CAA6B;AAC7B,8CAA4B;AAC5B,kEAAgD;AAChD,uDAAqC;AACrC,qDAAmC;AACnC,gDAA8B;AAC9B,4CAA0B;AAC1B,uDAAqC;AAErC,8CAA2B;AAE3B,iDAA+B;AAE/B,kDAAgC","sourcesContent":["export * from \"./Abilitazione\";\nexport * from \"./AdminBootstrapDtos\";\nexport * from \"./AbilitazioneMenu\";\nexport * from \"./AssignPermissionsToUserRequest\";\nexport * from \"./AssignRolesToUserRequest\";\nexport * from \"./AuthenticatedUserPayloadDto\";\nexport * from \"./BaseResponse\";\nexport * from \"./CatalogDtos\";\nexport * from \"./ConfirmResetPasswordRequest\";\nexport * from \"./UpdateEnabledStatusRequest\"\n\nexport * from \"./FiltriUtente\";\nexport * from \"./FederatedIdentityDtos\";\nexport * from \"./FederatedExchangeDtos\";\nexport * from \"./GetUserByTokenRequest\";\nexport * from \"./GetUserByTokenResponse\";\nexport * from \"./IntrospectionDtos\";\nexport * from \"./LoginAsDtos\";\nexport * from \"./LoginRequest\";\nexport * from \"./LoginResponse\";\nexport * from \"./Permission\";\nexport * from \"./PublicRegisterRequest\";\nexport * from \"./RefreshTokenDtos\";\nexport * from \"./RevokeTokenRequest\";\nexport * from \"./Role\";\nexport * from \"./SchemaDtos\";\nexport * from \"./ScopeDtos\";\nexport * from \"./SendResetPasswordEmailRequest\";\nexport * from \"./StatoRegistrazione\";\nexport * from \"./TipoAbilitazione\";\nexport * from \"./TokenResult\";\nexport * from \"./UserDto\";\nexport * from \"./UserGrantsResponse\";\n\nexport * from \"./RuoliMenu\"\n\nexport * from \"./ServiceToken\";\n\nexport * from './TwoFactorDtos';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/accessi-module/Dtos/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,uDAAqC;AACrC,8CAA4B;AAC5B,qDAAmC;AACnC,mEAAiD;AACjD,6DAA2C;AAC3C,gEAA8C;AAC9C,iDAA+B;AAC/B,gDAA8B;AAC9B,gEAA8C;AAC9C,+DAA4C;AAE5C,iDAA+B;AAC/B,0DAAwC;AACxC,0DAAwC;AACxC,0DAAwC;AACxC,2DAAyC;AACzC,sDAAoC;AACpC,gDAA8B;AAC9B,iDAA+B;AAC/B,kDAAgC;AAChC,+CAA6B;AAC7B,0DAAwC;AACxC,qDAAmC;AACnC,uDAAqC;AACrC,yCAAuB;AACvB,+CAA6B;AAC7B,8CAA4B;AAC5B,kEAAgD;AAChD,uDAAqC;AACrC,qDAAmC;AACnC,gDAA8B;AAC9B,4CAA0B;AAC1B,uDAAqC;AAErC,8CAA2B;AAE3B,iDAA+B;AAE/B,kDAAgC","sourcesContent":["export * from \"./Abilitazione\";\nexport * from \"./AdminBootstrapDtos\";\nexport * from \"./AuditDtos\";\nexport * from \"./AbilitazioneMenu\";\nexport * from \"./AssignPermissionsToUserRequest\";\nexport * from \"./AssignRolesToUserRequest\";\nexport * from \"./AuthenticatedUserPayloadDto\";\nexport * from \"./BaseResponse\";\nexport * from \"./CatalogDtos\";\nexport * from \"./ConfirmResetPasswordRequest\";\nexport * from \"./UpdateEnabledStatusRequest\"\n\nexport * from \"./FiltriUtente\";\nexport * from \"./FederatedIdentityDtos\";\nexport * from \"./FederatedExchangeDtos\";\nexport * from \"./GetUserByTokenRequest\";\nexport * from \"./GetUserByTokenResponse\";\nexport * from \"./IntrospectionDtos\";\nexport * from \"./LoginAsDtos\";\nexport * from \"./LoginRequest\";\nexport * from \"./LoginResponse\";\nexport * from \"./Permission\";\nexport * from \"./PublicRegisterRequest\";\nexport * from \"./RefreshTokenDtos\";\nexport * from \"./RevokeTokenRequest\";\nexport * from \"./Role\";\nexport * from \"./SchemaDtos\";\nexport * from \"./ScopeDtos\";\nexport * from \"./SendResetPasswordEmailRequest\";\nexport * from \"./StatoRegistrazione\";\nexport * from \"./TipoAbilitazione\";\nexport * from \"./TokenResult\";\nexport * from \"./UserDto\";\nexport * from \"./UserGrantsResponse\";\n\nexport * from \"./RuoliMenu\"\n\nexport * from \"./ServiceToken\";\n\nexport * from './TwoFactorDtos';\n"]}
|
|
@@ -25,6 +25,7 @@ export interface AccessiModuleInitializationResult {
|
|
|
25
25
|
export declare function initializeAccessiModule(app: Application, options: AccessiOptions): Promise<AccessiModuleInitializationResult>;
|
|
26
26
|
export { AccessiModule } from "./AccessiModule";
|
|
27
27
|
export { AccessiIntrospectionController } from "./Controllers/AccessiIntrospectionController";
|
|
28
|
+
export { AccessiAuditController } from "./Controllers/AccessiAuditController";
|
|
28
29
|
export { FederatedAuthExchangeController } from "./federated-auth/FederatedAuthExchangeController";
|
|
29
30
|
export type { AccessiTokenIntrospectionResult } from "./Services/AuthService/AuthService";
|
|
30
31
|
export { AccessiDatabaseUpdater } from "./database-updates/AccessiDatabaseUpdater";
|
|
@@ -38,7 +39,10 @@ export type { MemoryRateLimitStore, RateLimitDecision, RateLimitRedisClient, Rat
|
|
|
38
39
|
export { createAccessiEdgeRateLimitMiddleware } from './security/edgeRateLimit';
|
|
39
40
|
export type { AccessiEdgeRateLimitMiddleware, AccessiEdgeRateLimitOptions } from './security/edgeRateLimit';
|
|
40
41
|
export { assertValidAccessiOptions, validateAccessiOptions } from './security/validateOptions';
|
|
41
|
-
export { auditAccessi } from './security/audit';
|
|
42
|
+
export { auditAccessi, configureAccessiAudit, getAccessiAuditStore, redactAccessiAuditValue, resetAccessiAudit } from './security/audit';
|
|
43
|
+
export type { AccessiAuditOptions, AccessiAuditPage, AccessiAuditQuery, AccessiAuditQueryableSink, AccessiAuditRecord, AccessiAuditSink } from './security/audit';
|
|
44
|
+
export { createCallbackAccessiAuditSink, createHttpAccessiAuditSink, createMemoryAccessiAuditSink, createRedisAccessiAuditSink } from './security/auditSinks';
|
|
45
|
+
export type { HttpAccessiAuditSinkOptions, MemoryAccessiAuditSink, MemoryAccessiAuditSinkOptions, RedisAccessiAuditSinkOptions } from './security/auditSinks';
|
|
42
46
|
export { createMemorySessionRevocationStore, createRedisSessionRevocationStore, revokeAccessiUserSessions, revokeAccessiUserSessionsIfConfigured, isAccessiTokenRevoked, getSessionRevocationStore } from './security/sessionRevocation';
|
|
43
47
|
export type { MemorySessionRevocationStore, RedisSessionRevocationStoreOptions, SessionRevocationOptions, SessionRevocationRedisClient, SessionRevocationStore } from './security/sessionRevocation';
|
|
44
48
|
export { createMemoryRefreshTokenRotationStore, createRedisRefreshTokenRotationStore, consumeRefreshToken, getRefreshTokenRotationStore, isRefreshTokenFamilyRevoked, revokeRefreshTokenFamily } from './security/refreshTokenRotation';
|
|
@@ -26,9 +26,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
30
|
-
exports.
|
|
31
|
-
exports.createAccessiHealthModule = exports.readinessHttpStatus = exports.createAccessiLiveReport = exports.collectAccessiHealthStores = void 0;
|
|
29
|
+
exports.ServiceTokenService = exports.discoverCatalogScripts = exports.computeCatalogScriptChecksum = exports.leadingStatementKeyword = exports.analyzeCatalogScript = exports.splitSqlStatements = exports.listPendingCatalogScripts = exports.applyCatalogScripts = exports.AccessiCatalogMigrator = exports.revokeAccessiAccessTokenIfConfigured = exports.revokeAccessiAccessToken = exports.isAccessiAccessTokenRevoked = exports.getAccessTokenRevocationStore = exports.createRedisAccessTokenRevocationStore = exports.createMemoryAccessTokenRevocationStore = exports.revokeRefreshTokenFamily = exports.isRefreshTokenFamilyRevoked = exports.getRefreshTokenRotationStore = exports.consumeRefreshToken = exports.createRedisRefreshTokenRotationStore = exports.createMemoryRefreshTokenRotationStore = exports.getSessionRevocationStore = exports.isAccessiTokenRevoked = exports.revokeAccessiUserSessionsIfConfigured = exports.revokeAccessiUserSessions = exports.createRedisSessionRevocationStore = exports.createMemorySessionRevocationStore = exports.createRedisAccessiAuditSink = exports.createMemoryAccessiAuditSink = exports.createHttpAccessiAuditSink = exports.createCallbackAccessiAuditSink = exports.resetAccessiAudit = exports.redactAccessiAuditValue = exports.getAccessiAuditStore = exports.configureAccessiAudit = exports.auditAccessi = exports.validateAccessiOptions = exports.assertValidAccessiOptions = exports.createAccessiEdgeRateLimitMiddleware = exports.getDefaultRateLimitStore = exports.createRedisRateLimitStore = exports.createMemoryRateLimitStore = exports.getDefaultConsoleEntryStore = exports.createRedisConsoleEntryStore = exports.createMemoryConsoleEntryStore = exports.AccessiDatabaseUpdater = exports.FederatedAuthExchangeController = exports.AccessiAuditController = exports.AccessiIntrospectionController = exports.AccessiModule = void 0;
|
|
30
|
+
exports.verifyAccessiJwt = exports.resolveAccessiVerificationKeys = exports.getAccessiRefreshTokenVerificationConfig = exports.getAccessiRefreshTokenSigningConfig = exports.getAccessiAccessTokenVerificationConfig = exports.getAccessiAccessTokenSigningConfig = exports.instrumentAccessiRedisClient = exports.resetAccessiMetrics = exports.renderAccessiMetrics = exports.recordAccessiMetric = exports.recordAccessiDuration = exports.observeAccessiMetric = exports.getAccessiMetricsSink = exports.getAccessiMetricsRegistry = exports.createAccessiMetricsRegistry = exports.countAccessiMetric = exports.accessiMetricName = exports.isAccessiCsrfExemptPath = exports.parseAccessiCookieHeader = exports.applyAccessiAuthCookies = exports.clearAccessiAuthCookies = exports.setAccessiAuthCookies = exports.getAccessiRefreshTokenFromCookie = exports.getAccessiAccessTokenFromCookie = exports.resolveAccessiAuthCookieOptions = exports.createAccessiAuthCookieMiddleware = exports.resolveAccessiSecurityHeaders = exports.createAccessiSecurityHeadersMiddleware = exports.buildAccessiContentSecurityPolicy = exports.applyAccessiContentSecurityPolicy = exports.applyAccessiBaseSecurityHeaders = exports.setupAccessiJwks = exports.getAccessiJwksPath = exports.createAccessiJwksHandler = exports.buildAccessiJwks = exports.LOGIN_AS_QUERY_PARAM = exports.buildLoginAsUrl = exports.ACCESSI_EMAIL_NOT_CONFIGURED = exports.AccessiEmailNotConfiguredError = exports.isEmailConfigured = exports.assertEmailConfigured = exports.getAccessiServiceToken = exports.RequireServiceTokenScopes = exports.ServiceTokenGuard = exports.isValidAdminBootstrapToken = exports.clearAdminBootstrapToken = exports.getAdminBootstrapToken = exports.getOrCreateAdminBootstrapToken = exports.AdminBootstrapService = exports.SchemaExportService = void 0;
|
|
31
|
+
exports.createAccessiHealthModule = exports.readinessHttpStatus = exports.createAccessiLiveReport = exports.collectAccessiHealthStores = exports.checkAccessiDatabase = exports.checkAccessiReadiness = exports.ACCESSI_MODULE_SERVICES_LOCALS_KEY = exports.getAccessiModuleServices = exports.registerAccessiModuleServices = exports.accessiRequirement = exports.authenticateGen = exports.authorizeAccessi = exports.FederatedAuthService = void 0;
|
|
32
32
|
exports.initializeAccessiModule = initializeAccessiModule;
|
|
33
33
|
const express_1 = __importDefault(require("express"));
|
|
34
34
|
const core_1 = require("@nestjs/core");
|
|
@@ -156,6 +156,8 @@ var AccessiModule_2 = require("./AccessiModule");
|
|
|
156
156
|
Object.defineProperty(exports, "AccessiModule", { enumerable: true, get: function () { return AccessiModule_2.AccessiModule; } });
|
|
157
157
|
var AccessiIntrospectionController_1 = require("./Controllers/AccessiIntrospectionController");
|
|
158
158
|
Object.defineProperty(exports, "AccessiIntrospectionController", { enumerable: true, get: function () { return AccessiIntrospectionController_1.AccessiIntrospectionController; } });
|
|
159
|
+
var AccessiAuditController_1 = require("./Controllers/AccessiAuditController");
|
|
160
|
+
Object.defineProperty(exports, "AccessiAuditController", { enumerable: true, get: function () { return AccessiAuditController_1.AccessiAuditController; } });
|
|
159
161
|
var FederatedAuthExchangeController_1 = require("./federated-auth/FederatedAuthExchangeController");
|
|
160
162
|
Object.defineProperty(exports, "FederatedAuthExchangeController", { enumerable: true, get: function () { return FederatedAuthExchangeController_1.FederatedAuthExchangeController; } });
|
|
161
163
|
var AccessiDatabaseUpdater_1 = require("./database-updates/AccessiDatabaseUpdater");
|
|
@@ -175,6 +177,15 @@ Object.defineProperty(exports, "assertValidAccessiOptions", { enumerable: true,
|
|
|
175
177
|
Object.defineProperty(exports, "validateAccessiOptions", { enumerable: true, get: function () { return validateOptions_1.validateAccessiOptions; } });
|
|
176
178
|
var audit_1 = require("./security/audit");
|
|
177
179
|
Object.defineProperty(exports, "auditAccessi", { enumerable: true, get: function () { return audit_1.auditAccessi; } });
|
|
180
|
+
Object.defineProperty(exports, "configureAccessiAudit", { enumerable: true, get: function () { return audit_1.configureAccessiAudit; } });
|
|
181
|
+
Object.defineProperty(exports, "getAccessiAuditStore", { enumerable: true, get: function () { return audit_1.getAccessiAuditStore; } });
|
|
182
|
+
Object.defineProperty(exports, "redactAccessiAuditValue", { enumerable: true, get: function () { return audit_1.redactAccessiAuditValue; } });
|
|
183
|
+
Object.defineProperty(exports, "resetAccessiAudit", { enumerable: true, get: function () { return audit_1.resetAccessiAudit; } });
|
|
184
|
+
var auditSinks_1 = require("./security/auditSinks");
|
|
185
|
+
Object.defineProperty(exports, "createCallbackAccessiAuditSink", { enumerable: true, get: function () { return auditSinks_1.createCallbackAccessiAuditSink; } });
|
|
186
|
+
Object.defineProperty(exports, "createHttpAccessiAuditSink", { enumerable: true, get: function () { return auditSinks_1.createHttpAccessiAuditSink; } });
|
|
187
|
+
Object.defineProperty(exports, "createMemoryAccessiAuditSink", { enumerable: true, get: function () { return auditSinks_1.createMemoryAccessiAuditSink; } });
|
|
188
|
+
Object.defineProperty(exports, "createRedisAccessiAuditSink", { enumerable: true, get: function () { return auditSinks_1.createRedisAccessiAuditSink; } });
|
|
178
189
|
var sessionRevocation_1 = require("./security/sessionRevocation");
|
|
179
190
|
Object.defineProperty(exports, "createMemorySessionRevocationStore", { enumerable: true, get: function () { return sessionRevocation_1.createMemorySessionRevocationStore; } });
|
|
180
191
|
Object.defineProperty(exports, "createRedisSessionRevocationStore", { enumerable: true, get: function () { return sessionRevocation_1.createRedisSessionRevocationStore; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/accessi-module/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,0DAgHC;AA7KD,sDAAwD;AACxD,uCAA2C;AAC3C,+DAA0D;AAG1D,mDAAgE;AAChE,sCAAmC;AACnC,oEAAiE;AACjE,4DAKkC;AAClC,kEAIsC;AACtC,qDAAiE;AACjE,6CAAiD;AACjD,oEAA2E;AAC3E,sFAAmF;AACnF,sEAAsE;AACtE,0CAAuE;AACvE,4DAAgF;AAChF,gEAAoF;AACpF,wDAA2E;AAU3E,SAAS,sBAAsB,CAAC,OAAuB;;IACnD,MAAM,SAAS,GAAG,OAAO,CAAC,eAKzB,CAAC;IAEF,OAAO,GAAG,MAAA,SAAS,CAAC,IAAI,mCAAI,GAAG,IAAI,MAAA,SAAS,CAAC,IAAI,mCAAI,GAAG,OAA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uHAAA,wBAAwB,OAAA;AACxB,sHAAA,uBAAuB,OAAA;AAQ3B,mDAWiC;AAV7B,4GAAA,iBAAiB,OAAA;AACjB,6GAAA,kBAAkB,OAAA;AAClB,uHAAA,4BAA4B,OAAA;AAC5B,oHAAA,yBAAyB,OAAA;AACzB,gHAAA,qBAAqB,OAAA;AACrB,+GAAA,oBAAoB,OAAA;AACpB,gHAAA,qBAAqB,OAAA;AACrB,8GAAA,mBAAmB,OAAA;AACnB,+GAAA,oBAAoB,OAAA;AACpB,8GAAA,mBAAmB,OAAA;AAUvB,6DAA4E;AAAnE,4HAAA,4BAA4B,OAAA;AAErC,8DAOoC;AANhC,qIAAA,kCAAkC,OAAA;AAClC,0IAAA,uCAAuC,OAAA;AACvC,sIAAA,mCAAmC,OAAA;AACnC,2IAAA,wCAAwC,OAAA;AACxC,iIAAA,8BAA8B,OAAA;AAC9B,mHAAA,gBAAgB,OAAA;AAMpB,8EAA6E;AAApE,4HAAA,oBAAoB,OAAA;AAE7B,yCAAuB;AACvB,gEAGsC;AAFlC,mHAAA,gBAAgB,OAAA;AAChB,kHAAA,eAAe,OAAA;AAEnB,wEAAsE;AAA7D,yHAAA,kBAAkB,OAAA;AAC3B,mDAI0B;AAHtB,+HAAA,6BAA6B,OAAA;AAC7B,0HAAA,wBAAwB,OAAA;AACxB,oIAAA,kCAAkC,OAAA;AAUtC,gDAM4B;AALxB,kHAAA,qBAAqB,OAAA;AACrB,iHAAA,oBAAoB,OAAA;AACpB,uHAAA,0BAA0B,OAAA;AAC1B,oHAAA,uBAAuB,OAAA;AACvB,gHAAA,mBAAmB,OAAA;AAUvB,sCAA0D;AAAjD,iHAAA,yBAAyB,OAAA","sourcesContent":["import express, { Application, Request } from \"express\";\nimport { NestFactory } from \"@nestjs/core\";\nimport { ExpressAdapter } from \"@nestjs/platform-express\";\nimport type { INestApplication } from \"@nestjs/common\";\nimport type { OpenAPIObject } from \"@nestjs/swagger\";\nimport { AccessiModule, AccessiOptions } from \"./AccessiModule\";\nimport { Logger } from \"../Logger\";\nimport { AuthService } from \"./Services/AuthService/AuthService\";\nimport {\n buildOpenApiExcludePaths,\n isOpenApiRequestPath,\n resolveAccessiOpenApiOptions,\n setupOpenApi\n} from \"../openapi/OpenApiConfig\";\nimport {\n beginAccessiAuthInitialization,\n failAccessiAuthInitialization,\n setAccessiAuthService\n} from \"./middleware/authenticateGen\";\nimport { registerAccessiModuleServices } from \"./accessiRuntime\";\nimport { logAccessiStartup } from \"./startupLog\";\nimport { createAccessiValidationPipe } from './security/accessiValidation';\nimport { AccessiHttpExceptionFilter } from './security/AccessiHttpExceptionFilter';\nimport { assertEmailConfigured } from './security/emailConfiguration';\nimport { getAccessiJwksPath, setupAccessiJwks } from './security/jwks';\nimport { createAccessiEdgeRateLimitMiddleware } from './security/edgeRateLimit';\nimport { createAccessiSecurityHeadersMiddleware } from './security/securityHeaders';\nimport { createAccessiAuthCookieMiddleware } from './security/authCookies';\n\n/** Esito del bootstrap Express di Accessi. */\nexport interface AccessiModuleInitializationResult {\n /** Sotto-app Nest che serve `/api/accessi/*` e la documentazione. */\n nestApp: INestApplication;\n /** Documento OpenAPI generato, mergiabile nel documento unico dell'host. */\n document: OpenAPIObject;\n}\n\nfunction describeDatabaseTarget(options: AccessiOptions): string {\n const dbOptions = options.databaseOptions as {\n host?: string;\n port?: number;\n database?: string;\n user?: string;\n };\n\n return `${dbOptions.host ?? \"?\"}:${dbOptions.port ?? \"?\"} -> ${dbOptions.database ?? \"?\"} as ${dbOptions.user ?? \"?\"}`;\n}\n\n/**\n * Monta il modulo Accessi in un'applicazione Express gia esistente.\n *\n * Il bootstrap crea un host Nest isolato per le rotte `/api/accessi`, inizializza la\n * documentazione OpenAPI, validazione ed error handler, quindi rende disponibile\n * `authorizeAccessi` al resto dell'app.\n * Attendere questa Promise prima di aprire la porta HTTP: durante il bootstrap il middleware\n * restituisce `ACCESSI_AUTH_INITIALIZING` invece di autorizzare richieste parzialmente inizializzate.\n *\n * @param app Applicazione Express ospitante. Non viene sostituita ne vengono intercettate rotte estranee ad Accessi.\n * @param options Configurazione riservata del modulo; proviene normalmente da variabili d'ambiente o secret manager.\n * @returns Il sotto-app Nest e il documento OpenAPI generato (utile per il merge nell'host).\n */\nexport async function initializeAccessiModule(\n app: Application,\n options: AccessiOptions\n): Promise<AccessiModuleInitializationResult> {\n // Il servizio email e obbligatorio: reset password, 2FA e creazione utente ne dipendono.\n assertEmailConfigured(options);\n const logger: Logger = new Logger(\"initializeAccessiModule\");\n beginAccessiAuthInitialization();\n const startedAt = performance.now();\n const resolvedOpenApi = resolveAccessiOpenApiOptions(options.openapi);\n\n try {\n logger.info(\"Inizializzazione modulo accessi avviata.\");\n logger.info(`Target database accessi: ${describeDatabaseTarget(options)}`);\n logger.info(\n `Configurazione accessi: autoUpdateDatabase=${options.autoUpdateDatabase !== false}, legacyPasswordMigrationOnStartup=${options.legacyPasswordMigrationOnStartup !== false}`\n );\n const nestHostApp = express();\n if (options.http?.trustProxy !== undefined) {\n app.set('trust proxy', options.http.trustProxy);\n nestHostApp.set('trust proxy', options.http.trustProxy);\n }\n const jwksPath = getAccessiJwksPath(options);\n const isAccessiRoute = (path: string) =>\n path === \"/api/accessi\" ||\n path.startsWith(\"/api/accessi/\") ||\n isOpenApiRequestPath(path, resolvedOpenApi) ||\n (jwksPath !== undefined && path === jwksPath);\n const edgeRateLimit = options.edgeRateLimit\n ? createAccessiEdgeRateLimitMiddleware({\n ...options.edgeRateLimit,\n match: options.edgeRateLimit.match ?? ((path) => isAccessiRoute(path)),\n })\n : undefined;\n if (edgeRateLimit) {\n app.use(edgeRateLimit);\n }\n const authCookie = createAccessiAuthCookieMiddleware(options, isAccessiRoute);\n if (authCookie) {\n app.use(authCookie);\n }\n if (options.http?.securityHeaders !== false) {\n const securityHeaders = createAccessiSecurityHeadersMiddleware(\n options.http?.securityHeaders,\n isAccessiRoute,\n { isOpenApiUi: (path) => isOpenApiRequestPath(path, resolvedOpenApi) },\n );\n if (securityHeaders) {\n app.use(securityHeaders);\n }\n }\n\n app.use((req: Request, res, next) => {\n if (!isAccessiRoute(req.path)) {\n return next();\n }\n\n return nestHostApp(req, res, next);\n });\n\n setupAccessiJwks(app, options);\n if (jwksPath) {\n logger.info(`JWKS accessi disponibile su: ${jwksPath}`);\n }\n\n const nestExpressInstance = new ExpressAdapter(nestHostApp);\n\n const nestApp = await NestFactory.create(AccessiModule.forRoot(options), nestExpressInstance, {\n bufferLogs: options.bufferLogs !== false,\n ...(options.logger ? { logger: options.logger } : {})\n });\n logger.info(\"Applicazione Nest accessi creata.\");\n\n if (options.http?.cors !== false) {\n nestApp.enableCors(options.http?.cors ?? { exposedHeaders: ['X-Total-Count', 'X-CSRF-Token'] });\n }\n nestApp.useGlobalPipes(createAccessiValidationPipe());\n nestApp.useGlobalFilters(new AccessiHttpExceptionFilter());\n\n nestApp.setGlobalPrefix('api', {\n exclude: buildOpenApiExcludePaths(resolvedOpenApi)\n });\n\n const document = setupOpenApi(nestApp, resolvedOpenApi);\n logger.info(\"Avvio init del modulo accessi.\");\n await nestApp.init();\n logger.info(\"Init del modulo accessi completata.\");\n if (options.legacyPasswordMigrationOnStartup !== false) {\n logger.info(\"Avvio migrazione password legacy accessi.\");\n const passwordMigrationService = nestApp.get(AuthService);\n await passwordMigrationService.migrateLegacyEncryptedPasswords();\n logger.info(\"Migrazione password legacy accessi completata.\");\n }\n\n const accessiServices = registerAccessiModuleServices(app, nestApp);\n app.locals.accessiAuthService = accessiServices.authenticateGenService;\n setAccessiAuthService(accessiServices.authenticateGenService);\n logAccessiStartup(options, resolvedOpenApi);\n const elapsedMs = performance.now() - startedAt;\n logger.info(`Accessi initialized. Tempo totale bootstrap: ${elapsedMs.toFixed(2)} ms`);\n\n return { nestApp, document };\n } catch (error) {\n failAccessiAuthInitialization(error);\n logger.error(\n \"Errore in initialize AccessiModule:\",\n error instanceof Error\n ? { name: error.name, message: error.message, stack: error.stack }\n : { error: String(error) }\n );\n throw error;\n }\n}\n\nexport { AccessiModule } from \"./AccessiModule\";\nexport { AccessiIntrospectionController } from \"./Controllers/AccessiIntrospectionController\";\nexport { FederatedAuthExchangeController } from \"./federated-auth/FederatedAuthExchangeController\";\nexport type { AccessiTokenIntrospectionResult } from \"./Services/AuthService/AuthService\";\nexport { AccessiDatabaseUpdater } from \"./database-updates/AccessiDatabaseUpdater\";\nexport type { AccessiOptions, EmailOptions, JwtOptions, ExtensionFieldsOptions, PublicAuthRateLimitOptions, PublicAuthRateLimitRuleOptions } from \"./AccessiModule\";\nexport type { PublicRegistrationOptions, FederatedAuthenticationOptions, ServiceTokenOptions } from \"./AccessiModule\";\nexport type { CatalogScriptsOptions, CatalogScriptChecksumPolicy, ConsoleEntryOptions } from \"./AccessiModule\";\nexport {\n createMemoryConsoleEntryStore,\n createRedisConsoleEntryStore,\n getDefaultConsoleEntryStore\n} from './security/consoleEntry';\nexport type {\n ConsoleEntryRedisClient,\n ConsoleEntryRecord,\n ConsoleEntryStore,\n ConsoleEntryTicket,\n MemoryConsoleEntryStore,\n RedisConsoleEntryStoreOptions\n} from './security/consoleEntry';\nexport {\n createMemoryRateLimitStore,\n createRedisRateLimitStore,\n getDefaultRateLimitStore\n} from './security/rateLimitStore';\nexport type {\n MemoryRateLimitStore,\n RateLimitDecision,\n RateLimitRedisClient,\n RateLimitStore,\n RedisRateLimitStoreOptions\n} from './security/rateLimitStore';\nexport { createAccessiEdgeRateLimitMiddleware } from './security/edgeRateLimit';\nexport type {\n AccessiEdgeRateLimitMiddleware,\n AccessiEdgeRateLimitOptions\n} from './security/edgeRateLimit';\nexport {\n assertValidAccessiOptions,\n validateAccessiOptions\n} from './security/validateOptions';\nexport { auditAccessi } from './security/audit';\nexport {\n createMemorySessionRevocationStore,\n createRedisSessionRevocationStore,\n revokeAccessiUserSessions,\n revokeAccessiUserSessionsIfConfigured,\n isAccessiTokenRevoked,\n getSessionRevocationStore\n} from './security/sessionRevocation';\nexport type {\n MemorySessionRevocationStore,\n RedisSessionRevocationStoreOptions,\n SessionRevocationOptions,\n SessionRevocationRedisClient,\n SessionRevocationStore\n} from './security/sessionRevocation';\nexport {\n createMemoryRefreshTokenRotationStore,\n createRedisRefreshTokenRotationStore,\n consumeRefreshToken,\n getRefreshTokenRotationStore,\n isRefreshTokenFamilyRevoked,\n revokeRefreshTokenFamily\n} from './security/refreshTokenRotation';\nexport type {\n MemoryRefreshTokenRotationStore,\n RedisRefreshTokenRotationStoreOptions,\n RefreshTokenConsumeResult,\n RefreshTokenRotationOptions,\n RefreshTokenRotationRedisClient,\n RefreshTokenRotationStore\n} from './security/refreshTokenRotation';\nexport {\n createMemoryAccessTokenRevocationStore,\n createRedisAccessTokenRevocationStore,\n getAccessTokenRevocationStore,\n isAccessiAccessTokenRevoked,\n revokeAccessiAccessToken,\n revokeAccessiAccessTokenIfConfigured\n} from './security/accessTokenRevocation';\nexport type {\n AccessTokenRevocationOptions,\n AccessTokenRevocationRedisClient,\n AccessTokenRevocationStore,\n MemoryAccessTokenRevocationStore,\n RedisAccessTokenRevocationStoreOptions\n} from './security/accessTokenRevocation';\nexport type {\n AccessiOptionsValidationIssue,\n AccessiOptionsValidationResult\n} from './security/validateOptions';\nexport {\n AccessiCatalogMigrator,\n applyCatalogScripts,\n listPendingCatalogScripts,\n splitSqlStatements,\n analyzeCatalogScript,\n leadingStatementKeyword,\n computeCatalogScriptChecksum,\n discoverCatalogScripts\n} from \"./database-updates/AccessiCatalogMigrator\";\nexport type { CatalogMigrationReport, CatalogScriptMigration } from \"./database-updates/AccessiCatalogMigrator\";\nexport { ServiceTokenService } from './Services/ServiceTokenService/ServiceTokenService';\nexport type {\n ServiceTokenMetadata,\n IssuedServiceToken,\n VerifiedServiceToken,\n IssueServiceTokenInput\n} from './Services/ServiceTokenService/ServiceTokenService';\nexport { SchemaExportService } from './Services/SchemaExportService/SchemaExportService';\nexport type { SchemaDdlResult, SchemaDdlSection, SchemaEntitiesResult } from './Services/SchemaExportService/SchemaExportService';\nexport { AdminBootstrapService } from './Services/AdminBootstrapService/AdminBootstrapService';\nexport type { BootstrapAdminResult } from './Services/AdminBootstrapService/AdminBootstrapService';\nexport {\n getOrCreateAdminBootstrapToken,\n getAdminBootstrapToken,\n clearAdminBootstrapToken,\n isValidAdminBootstrapToken\n} from './security/adminBootstrap';\nexport { ServiceTokenGuard, RequireServiceTokenScopes, getAccessiServiceToken } from './security/serviceTokenGuard';\nexport { assertEmailConfigured, isEmailConfigured, AccessiEmailNotConfiguredError, ACCESSI_EMAIL_NOT_CONFIGURED } from './security/emailConfiguration';\nexport { buildLoginAsUrl, LOGIN_AS_QUERY_PARAM } from './security/loginAs';\nexport {\n buildAccessiJwks,\n createAccessiJwksHandler,\n getAccessiJwksPath,\n setupAccessiJwks\n} from './security/jwks';\nexport type { AccessiJwksDocument, AccessiJwksKey } from './security/jwks';\nexport {\n applyAccessiBaseSecurityHeaders,\n applyAccessiContentSecurityPolicy,\n buildAccessiContentSecurityPolicy,\n createAccessiSecurityHeadersMiddleware,\n resolveAccessiSecurityHeaders\n} from './security/securityHeaders';\nexport type {\n AccessiCspDirectives,\n AccessiCspOptions,\n AccessiCspSurface,\n AccessiSecurityHeadersOptions,\n AccessiSecurityHeadersSetting,\n ResolvedAccessiCsp,\n ResolvedAccessiSecurityHeaders\n} from './security/securityHeaders';\nexport {\n createAccessiAuthCookieMiddleware,\n resolveAccessiAuthCookieOptions,\n getAccessiAccessTokenFromCookie,\n getAccessiRefreshTokenFromCookie,\n setAccessiAuthCookies,\n clearAccessiAuthCookies,\n applyAccessiAuthCookies,\n parseAccessiCookieHeader,\n isAccessiCsrfExemptPath\n} from './security/authCookies';\nexport type {\n AccessiAuthCookieOptions,\n AccessiAuthCookieSetting,\n AccessiAuthTokenPair,\n ResolvedAccessiAuthCookieOptions\n} from './security/authCookies';\nexport {\n accessiMetricName,\n countAccessiMetric,\n createAccessiMetricsRegistry,\n getAccessiMetricsRegistry,\n getAccessiMetricsSink,\n observeAccessiMetric,\n recordAccessiDuration,\n recordAccessiMetric,\n renderAccessiMetrics,\n resetAccessiMetrics\n} from './observability/metrics';\nexport type {\n AccessiMetricLabelValue,\n AccessiMetricLabels,\n AccessiMetricsOptions,\n AccessiMetricsRegistry,\n AccessiMetricsSink,\n AccessiMetricsSnapshot\n} from './observability/metrics';\nexport { instrumentAccessiRedisClient } from './observability/redisMetrics';\nexport type { AccessiRedisEvalClient } from './observability/redisMetrics';\nexport {\n getAccessiAccessTokenSigningConfig,\n getAccessiAccessTokenVerificationConfig,\n getAccessiRefreshTokenSigningConfig,\n getAccessiRefreshTokenVerificationConfig,\n resolveAccessiVerificationKeys,\n verifyAccessiJwt\n} from './security/jwtTokenOptions';\nexport type {\n AccessiJwtVerificationConfig,\n AccessiUnknownKeyIdEvent\n} from './security/jwtTokenOptions';\nexport { FederatedAuthService } from './federated-auth/FederatedAuthService';\nexport type { FederatedAuthenticationResult, FederatedIdentity, FederatedProvider, VerifiedFederatedIdentity } from './federated-auth/FederatedAuthTypes';\nexport * from \"./Dtos\";\nexport {\n authorizeAccessi,\n authenticateGen\n} from \"./middleware/authenticateGen\";\nexport { accessiRequirement } from \"./middleware/accessiRequirements\";\nexport {\n registerAccessiModuleServices,\n getAccessiModuleServices,\n ACCESSI_MODULE_SERVICES_LOCALS_KEY\n} from \"./accessiRuntime\";\nexport type { AccessiModuleServices } from \"./accessiRuntime\";\nexport type {\n AccessiAuthorizationOptions,\n AccessiRequirementNode,\n AccessiCustomRequirementContext,\n AccessiCustomRequirementHandler\n} from \"./middleware/accessiRequirements\";\n\nexport {\n checkAccessiReadiness,\n checkAccessiDatabase,\n collectAccessiHealthStores,\n createAccessiLiveReport,\n readinessHttpStatus\n} from './health/readiness';\nexport type {\n AccessiHealthCheckResult,\n AccessiHealthStore,\n AccessiLiveReport,\n AccessiReadinessCheck,\n AccessiReadinessDependencies,\n AccessiReadinessReport\n} from './health/readiness';\nexport { createAccessiHealthModule } from './health/nest';\nexport type { AccessiHealthModuleOptions } from './health/nest';\n\n"]}
|
|
1
|
+
{"version":3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8DAOoC;AANhC,qIAAA,kCAAkC,OAAA;AAClC,0IAAA,uCAAuC,OAAA;AACvC,sIAAA,mCAAmC,OAAA;AACnC,2IAAA,wCAAwC,OAAA;AACxC,iIAAA,8BAA8B,OAAA;AAC9B,mHAAA,gBAAgB,OAAA;AAMpB,8EAA6E;AAApE,4HAAA,oBAAoB,OAAA;AAE7B,yCAAuB;AACvB,gEAGsC;AAFlC,mHAAA,gBAAgB,OAAA;AAChB,kHAAA,eAAe,OAAA;AAEnB,wEAAsE;AAA7D,yHAAA,kBAAkB,OAAA;AAC3B,mDAI0B;AAHtB,+HAAA,6BAA6B,OAAA;AAC7B,0HAAA,wBAAwB,OAAA;AACxB,oIAAA,kCAAkC,OAAA;AAUtC,gDAM4B;AALxB,kHAAA,qBAAqB,OAAA;AACrB,iHAAA,oBAAoB,OAAA;AACpB,uHAAA,0BAA0B,OAAA;AAC1B,oHAAA,uBAAuB,OAAA;AACvB,gHAAA,mBAAmB,OAAA;AAUvB,sCAA0D;AAAjD,iHAAA,yBAAyB,OAAA","sourcesContent":["import express, { Application, Request } from \"express\";\nimport { NestFactory } from \"@nestjs/core\";\nimport { ExpressAdapter } from \"@nestjs/platform-express\";\nimport type { INestApplication } from \"@nestjs/common\";\nimport type { OpenAPIObject } from \"@nestjs/swagger\";\nimport { AccessiModule, AccessiOptions } from \"./AccessiModule\";\nimport { Logger } from \"../Logger\";\nimport { AuthService } from \"./Services/AuthService/AuthService\";\nimport {\n buildOpenApiExcludePaths,\n isOpenApiRequestPath,\n resolveAccessiOpenApiOptions,\n setupOpenApi\n} from \"../openapi/OpenApiConfig\";\nimport {\n beginAccessiAuthInitialization,\n failAccessiAuthInitialization,\n setAccessiAuthService\n} from \"./middleware/authenticateGen\";\nimport { registerAccessiModuleServices } from \"./accessiRuntime\";\nimport { logAccessiStartup } from \"./startupLog\";\nimport { createAccessiValidationPipe } from './security/accessiValidation';\nimport { AccessiHttpExceptionFilter } from './security/AccessiHttpExceptionFilter';\nimport { assertEmailConfigured } from './security/emailConfiguration';\nimport { getAccessiJwksPath, setupAccessiJwks } from './security/jwks';\nimport { createAccessiEdgeRateLimitMiddleware } from './security/edgeRateLimit';\nimport { createAccessiSecurityHeadersMiddleware } from './security/securityHeaders';\nimport { createAccessiAuthCookieMiddleware } from './security/authCookies';\n\n/** Esito del bootstrap Express di Accessi. */\nexport interface AccessiModuleInitializationResult {\n /** Sotto-app Nest che serve `/api/accessi/*` e la documentazione. */\n nestApp: INestApplication;\n /** Documento OpenAPI generato, mergiabile nel documento unico dell'host. */\n document: OpenAPIObject;\n}\n\nfunction describeDatabaseTarget(options: AccessiOptions): string {\n const dbOptions = options.databaseOptions as {\n host?: string;\n port?: number;\n database?: string;\n user?: string;\n };\n\n return `${dbOptions.host ?? \"?\"}:${dbOptions.port ?? \"?\"} -> ${dbOptions.database ?? \"?\"} as ${dbOptions.user ?? \"?\"}`;\n}\n\n/**\n * Monta il modulo Accessi in un'applicazione Express gia esistente.\n *\n * Il bootstrap crea un host Nest isolato per le rotte `/api/accessi`, inizializza la\n * documentazione OpenAPI, validazione ed error handler, quindi rende disponibile\n * `authorizeAccessi` al resto dell'app.\n * Attendere questa Promise prima di aprire la porta HTTP: durante il bootstrap il middleware\n * restituisce `ACCESSI_AUTH_INITIALIZING` invece di autorizzare richieste parzialmente inizializzate.\n *\n * @param app Applicazione Express ospitante. Non viene sostituita ne vengono intercettate rotte estranee ad Accessi.\n * @param options Configurazione riservata del modulo; proviene normalmente da variabili d'ambiente o secret manager.\n * @returns Il sotto-app Nest e il documento OpenAPI generato (utile per il merge nell'host).\n */\nexport async function initializeAccessiModule(\n app: Application,\n options: AccessiOptions\n): Promise<AccessiModuleInitializationResult> {\n // Il servizio email e obbligatorio: reset password, 2FA e creazione utente ne dipendono.\n assertEmailConfigured(options);\n const logger: Logger = new Logger(\"initializeAccessiModule\");\n beginAccessiAuthInitialization();\n const startedAt = performance.now();\n const resolvedOpenApi = resolveAccessiOpenApiOptions(options.openapi);\n\n try {\n logger.info(\"Inizializzazione modulo accessi avviata.\");\n logger.info(`Target database accessi: ${describeDatabaseTarget(options)}`);\n logger.info(\n `Configurazione accessi: autoUpdateDatabase=${options.autoUpdateDatabase !== false}, legacyPasswordMigrationOnStartup=${options.legacyPasswordMigrationOnStartup !== false}`\n );\n const nestHostApp = express();\n if (options.http?.trustProxy !== undefined) {\n app.set('trust proxy', options.http.trustProxy);\n nestHostApp.set('trust proxy', options.http.trustProxy);\n }\n const jwksPath = getAccessiJwksPath(options);\n const isAccessiRoute = (path: string) =>\n path === \"/api/accessi\" ||\n path.startsWith(\"/api/accessi/\") ||\n isOpenApiRequestPath(path, resolvedOpenApi) ||\n (jwksPath !== undefined && path === jwksPath);\n const edgeRateLimit = options.edgeRateLimit\n ? createAccessiEdgeRateLimitMiddleware({\n ...options.edgeRateLimit,\n match: options.edgeRateLimit.match ?? ((path) => isAccessiRoute(path)),\n })\n : undefined;\n if (edgeRateLimit) {\n app.use(edgeRateLimit);\n }\n const authCookie = createAccessiAuthCookieMiddleware(options, isAccessiRoute);\n if (authCookie) {\n app.use(authCookie);\n }\n if (options.http?.securityHeaders !== false) {\n const securityHeaders = createAccessiSecurityHeadersMiddleware(\n options.http?.securityHeaders,\n isAccessiRoute,\n { isOpenApiUi: (path) => isOpenApiRequestPath(path, resolvedOpenApi) },\n );\n if (securityHeaders) {\n app.use(securityHeaders);\n }\n }\n\n app.use((req: Request, res, next) => {\n if (!isAccessiRoute(req.path)) {\n return next();\n }\n\n return nestHostApp(req, res, next);\n });\n\n setupAccessiJwks(app, options);\n if (jwksPath) {\n logger.info(`JWKS accessi disponibile su: ${jwksPath}`);\n }\n\n const nestExpressInstance = new ExpressAdapter(nestHostApp);\n\n const nestApp = await NestFactory.create(AccessiModule.forRoot(options), nestExpressInstance, {\n bufferLogs: options.bufferLogs !== false,\n ...(options.logger ? { logger: options.logger } : {})\n });\n logger.info(\"Applicazione Nest accessi creata.\");\n\n if (options.http?.cors !== false) {\n nestApp.enableCors(options.http?.cors ?? { exposedHeaders: ['X-Total-Count', 'X-CSRF-Token'] });\n }\n nestApp.useGlobalPipes(createAccessiValidationPipe());\n nestApp.useGlobalFilters(new AccessiHttpExceptionFilter());\n\n nestApp.setGlobalPrefix('api', {\n exclude: buildOpenApiExcludePaths(resolvedOpenApi)\n });\n\n const document = setupOpenApi(nestApp, resolvedOpenApi);\n logger.info(\"Avvio init del modulo accessi.\");\n await nestApp.init();\n logger.info(\"Init del modulo accessi completata.\");\n if (options.legacyPasswordMigrationOnStartup !== false) {\n logger.info(\"Avvio migrazione password legacy accessi.\");\n const passwordMigrationService = nestApp.get(AuthService);\n await passwordMigrationService.migrateLegacyEncryptedPasswords();\n logger.info(\"Migrazione password legacy accessi completata.\");\n }\n\n const accessiServices = registerAccessiModuleServices(app, nestApp);\n app.locals.accessiAuthService = accessiServices.authenticateGenService;\n setAccessiAuthService(accessiServices.authenticateGenService);\n logAccessiStartup(options, resolvedOpenApi);\n const elapsedMs = performance.now() - startedAt;\n logger.info(`Accessi initialized. Tempo totale bootstrap: ${elapsedMs.toFixed(2)} ms`);\n\n return { nestApp, document };\n } catch (error) {\n failAccessiAuthInitialization(error);\n logger.error(\n \"Errore in initialize AccessiModule:\",\n error instanceof Error\n ? { name: error.name, message: error.message, stack: error.stack }\n : { error: String(error) }\n );\n throw error;\n }\n}\n\nexport { AccessiModule } from \"./AccessiModule\";\nexport { AccessiIntrospectionController } from \"./Controllers/AccessiIntrospectionController\";\nexport { AccessiAuditController } from \"./Controllers/AccessiAuditController\";\nexport { FederatedAuthExchangeController } from \"./federated-auth/FederatedAuthExchangeController\";\nexport type { AccessiTokenIntrospectionResult } from \"./Services/AuthService/AuthService\";\nexport { AccessiDatabaseUpdater } from \"./database-updates/AccessiDatabaseUpdater\";\nexport type { AccessiOptions, EmailOptions, JwtOptions, ExtensionFieldsOptions, PublicAuthRateLimitOptions, PublicAuthRateLimitRuleOptions } from \"./AccessiModule\";\nexport type { PublicRegistrationOptions, FederatedAuthenticationOptions, ServiceTokenOptions } from \"./AccessiModule\";\nexport type { CatalogScriptsOptions, CatalogScriptChecksumPolicy, ConsoleEntryOptions } from \"./AccessiModule\";\nexport {\n createMemoryConsoleEntryStore,\n createRedisConsoleEntryStore,\n getDefaultConsoleEntryStore\n} from './security/consoleEntry';\nexport type {\n ConsoleEntryRedisClient,\n ConsoleEntryRecord,\n ConsoleEntryStore,\n ConsoleEntryTicket,\n MemoryConsoleEntryStore,\n RedisConsoleEntryStoreOptions\n} from './security/consoleEntry';\nexport {\n createMemoryRateLimitStore,\n createRedisRateLimitStore,\n getDefaultRateLimitStore\n} from './security/rateLimitStore';\nexport type {\n MemoryRateLimitStore,\n RateLimitDecision,\n RateLimitRedisClient,\n RateLimitStore,\n RedisRateLimitStoreOptions\n} from './security/rateLimitStore';\nexport { createAccessiEdgeRateLimitMiddleware } from './security/edgeRateLimit';\nexport type {\n AccessiEdgeRateLimitMiddleware,\n AccessiEdgeRateLimitOptions\n} from './security/edgeRateLimit';\nexport {\n assertValidAccessiOptions,\n validateAccessiOptions\n} from './security/validateOptions';\nexport {\n auditAccessi,\n configureAccessiAudit,\n getAccessiAuditStore,\n redactAccessiAuditValue,\n resetAccessiAudit\n} from './security/audit';\nexport type {\n AccessiAuditOptions,\n AccessiAuditPage,\n AccessiAuditQuery,\n AccessiAuditQueryableSink,\n AccessiAuditRecord,\n AccessiAuditSink\n} from './security/audit';\nexport {\n createCallbackAccessiAuditSink,\n createHttpAccessiAuditSink,\n createMemoryAccessiAuditSink,\n createRedisAccessiAuditSink\n} from './security/auditSinks';\nexport type {\n HttpAccessiAuditSinkOptions,\n MemoryAccessiAuditSink,\n MemoryAccessiAuditSinkOptions,\n RedisAccessiAuditSinkOptions\n} from './security/auditSinks';\nexport {\n createMemorySessionRevocationStore,\n createRedisSessionRevocationStore,\n revokeAccessiUserSessions,\n revokeAccessiUserSessionsIfConfigured,\n isAccessiTokenRevoked,\n getSessionRevocationStore\n} from './security/sessionRevocation';\nexport type {\n MemorySessionRevocationStore,\n RedisSessionRevocationStoreOptions,\n SessionRevocationOptions,\n SessionRevocationRedisClient,\n SessionRevocationStore\n} from './security/sessionRevocation';\nexport {\n createMemoryRefreshTokenRotationStore,\n createRedisRefreshTokenRotationStore,\n consumeRefreshToken,\n getRefreshTokenRotationStore,\n isRefreshTokenFamilyRevoked,\n revokeRefreshTokenFamily\n} from './security/refreshTokenRotation';\nexport type {\n MemoryRefreshTokenRotationStore,\n RedisRefreshTokenRotationStoreOptions,\n RefreshTokenConsumeResult,\n RefreshTokenRotationOptions,\n RefreshTokenRotationRedisClient,\n RefreshTokenRotationStore\n} from './security/refreshTokenRotation';\nexport {\n createMemoryAccessTokenRevocationStore,\n createRedisAccessTokenRevocationStore,\n getAccessTokenRevocationStore,\n isAccessiAccessTokenRevoked,\n revokeAccessiAccessToken,\n revokeAccessiAccessTokenIfConfigured\n} from './security/accessTokenRevocation';\nexport type {\n AccessTokenRevocationOptions,\n AccessTokenRevocationRedisClient,\n AccessTokenRevocationStore,\n MemoryAccessTokenRevocationStore,\n RedisAccessTokenRevocationStoreOptions\n} from './security/accessTokenRevocation';\nexport type {\n AccessiOptionsValidationIssue,\n AccessiOptionsValidationResult\n} from './security/validateOptions';\nexport {\n AccessiCatalogMigrator,\n applyCatalogScripts,\n listPendingCatalogScripts,\n splitSqlStatements,\n analyzeCatalogScript,\n leadingStatementKeyword,\n computeCatalogScriptChecksum,\n discoverCatalogScripts\n} from \"./database-updates/AccessiCatalogMigrator\";\nexport type { CatalogMigrationReport, CatalogScriptMigration } from \"./database-updates/AccessiCatalogMigrator\";\nexport { ServiceTokenService } from './Services/ServiceTokenService/ServiceTokenService';\nexport type {\n ServiceTokenMetadata,\n IssuedServiceToken,\n VerifiedServiceToken,\n IssueServiceTokenInput\n} from './Services/ServiceTokenService/ServiceTokenService';\nexport { SchemaExportService } from './Services/SchemaExportService/SchemaExportService';\nexport type { SchemaDdlResult, SchemaDdlSection, SchemaEntitiesResult } from './Services/SchemaExportService/SchemaExportService';\nexport { AdminBootstrapService } from './Services/AdminBootstrapService/AdminBootstrapService';\nexport type { BootstrapAdminResult } from './Services/AdminBootstrapService/AdminBootstrapService';\nexport {\n getOrCreateAdminBootstrapToken,\n getAdminBootstrapToken,\n clearAdminBootstrapToken,\n isValidAdminBootstrapToken\n} from './security/adminBootstrap';\nexport { ServiceTokenGuard, RequireServiceTokenScopes, getAccessiServiceToken } from './security/serviceTokenGuard';\nexport { assertEmailConfigured, isEmailConfigured, AccessiEmailNotConfiguredError, ACCESSI_EMAIL_NOT_CONFIGURED } from './security/emailConfiguration';\nexport { buildLoginAsUrl, LOGIN_AS_QUERY_PARAM } from './security/loginAs';\nexport {\n buildAccessiJwks,\n createAccessiJwksHandler,\n getAccessiJwksPath,\n setupAccessiJwks\n} from './security/jwks';\nexport type { AccessiJwksDocument, AccessiJwksKey } from './security/jwks';\nexport {\n applyAccessiBaseSecurityHeaders,\n applyAccessiContentSecurityPolicy,\n buildAccessiContentSecurityPolicy,\n createAccessiSecurityHeadersMiddleware,\n resolveAccessiSecurityHeaders\n} from './security/securityHeaders';\nexport type {\n AccessiCspDirectives,\n AccessiCspOptions,\n AccessiCspSurface,\n AccessiSecurityHeadersOptions,\n AccessiSecurityHeadersSetting,\n ResolvedAccessiCsp,\n ResolvedAccessiSecurityHeaders\n} from './security/securityHeaders';\nexport {\n createAccessiAuthCookieMiddleware,\n resolveAccessiAuthCookieOptions,\n getAccessiAccessTokenFromCookie,\n getAccessiRefreshTokenFromCookie,\n setAccessiAuthCookies,\n clearAccessiAuthCookies,\n applyAccessiAuthCookies,\n parseAccessiCookieHeader,\n isAccessiCsrfExemptPath\n} from './security/authCookies';\nexport type {\n AccessiAuthCookieOptions,\n AccessiAuthCookieSetting,\n AccessiAuthTokenPair,\n ResolvedAccessiAuthCookieOptions\n} from './security/authCookies';\nexport {\n accessiMetricName,\n countAccessiMetric,\n createAccessiMetricsRegistry,\n getAccessiMetricsRegistry,\n getAccessiMetricsSink,\n observeAccessiMetric,\n recordAccessiDuration,\n recordAccessiMetric,\n renderAccessiMetrics,\n resetAccessiMetrics\n} from './observability/metrics';\nexport type {\n AccessiMetricLabelValue,\n AccessiMetricLabels,\n AccessiMetricsOptions,\n AccessiMetricsRegistry,\n AccessiMetricsSink,\n AccessiMetricsSnapshot\n} from './observability/metrics';\nexport { instrumentAccessiRedisClient } from './observability/redisMetrics';\nexport type { AccessiRedisEvalClient } from './observability/redisMetrics';\nexport {\n getAccessiAccessTokenSigningConfig,\n getAccessiAccessTokenVerificationConfig,\n getAccessiRefreshTokenSigningConfig,\n getAccessiRefreshTokenVerificationConfig,\n resolveAccessiVerificationKeys,\n verifyAccessiJwt\n} from './security/jwtTokenOptions';\nexport type {\n AccessiJwtVerificationConfig,\n AccessiUnknownKeyIdEvent\n} from './security/jwtTokenOptions';\nexport { FederatedAuthService } from './federated-auth/FederatedAuthService';\nexport type { FederatedAuthenticationResult, FederatedIdentity, FederatedProvider, VerifiedFederatedIdentity } from './federated-auth/FederatedAuthTypes';\nexport * from \"./Dtos\";\nexport {\n authorizeAccessi,\n authenticateGen\n} from \"./middleware/authenticateGen\";\nexport { accessiRequirement } from \"./middleware/accessiRequirements\";\nexport {\n registerAccessiModuleServices,\n getAccessiModuleServices,\n ACCESSI_MODULE_SERVICES_LOCALS_KEY\n} from \"./accessiRuntime\";\nexport type { AccessiModuleServices } from \"./accessiRuntime\";\nexport type {\n AccessiAuthorizationOptions,\n AccessiRequirementNode,\n AccessiCustomRequirementContext,\n AccessiCustomRequirementHandler\n} from \"./middleware/accessiRequirements\";\n\nexport {\n checkAccessiReadiness,\n checkAccessiDatabase,\n collectAccessiHealthStores,\n createAccessiLiveReport,\n readinessHttpStatus\n} from './health/readiness';\nexport type {\n AccessiHealthCheckResult,\n AccessiHealthStore,\n AccessiLiveReport,\n AccessiReadinessCheck,\n AccessiReadinessDependencies,\n AccessiReadinessReport\n} from './health/readiness';\nexport { createAccessiHealthModule } from './health/nest';\nexport type { AccessiHealthModuleOptions } from './health/nest';\n\n"]}
|
|
@@ -1,7 +1,72 @@
|
|
|
1
|
+
/** Record di audit normalizzato e gia redatto. */
|
|
2
|
+
export interface AccessiAuditRecord {
|
|
3
|
+
event: string;
|
|
4
|
+
timestamp: string;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
/** Destinazione di un record di audit. */
|
|
8
|
+
export interface AccessiAuditSink {
|
|
9
|
+
/** Nome usato nelle metriche di errore del sink. */
|
|
10
|
+
name?: string;
|
|
11
|
+
write(record: AccessiAuditRecord): void | Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export interface AccessiAuditQuery {
|
|
14
|
+
event?: string;
|
|
15
|
+
from?: string;
|
|
16
|
+
to?: string;
|
|
17
|
+
codiceUtente?: number;
|
|
18
|
+
limit?: number;
|
|
19
|
+
offset?: number;
|
|
20
|
+
order?: 'asc' | 'desc';
|
|
21
|
+
}
|
|
22
|
+
export interface AccessiAuditPage {
|
|
23
|
+
records: AccessiAuditRecord[];
|
|
24
|
+
total: number;
|
|
25
|
+
limit: number;
|
|
26
|
+
offset: number;
|
|
27
|
+
}
|
|
28
|
+
/** Sink interrogabile dagli endpoint amministrativi e dalla retention. */
|
|
29
|
+
export interface AccessiAuditQueryableSink extends AccessiAuditSink {
|
|
30
|
+
query(filter?: AccessiAuditQuery): Promise<AccessiAuditPage>;
|
|
31
|
+
purge(before: Date): Promise<number>;
|
|
32
|
+
}
|
|
33
|
+
/** Opzioni di audit del modulo. */
|
|
34
|
+
export interface AccessiAuditOptions {
|
|
35
|
+
/** `false` disattiva i sink ma lascia il log strutturato. Default: abilitati. */
|
|
36
|
+
enabled?: boolean;
|
|
37
|
+
/** Sink aggiuntivi (HTTP, DB, OpenTelemetry). */
|
|
38
|
+
sinks?: AccessiAuditSink[];
|
|
39
|
+
/** Sink interrogabile usato da `/api/accessi/audit`. Default: primo sink queryable. */
|
|
40
|
+
store?: AccessiAuditQueryableSink;
|
|
41
|
+
/** Giorni di retention applicati ai sink queryable. Default: nessuna scadenza automatica. */
|
|
42
|
+
retentionDays?: number;
|
|
43
|
+
/** Chiavi aggiuntive da redigere, oltre a quelle predefinite. */
|
|
44
|
+
redact?: string[];
|
|
45
|
+
/** Scrivi anche sul Logger strutturato. Default: true. */
|
|
46
|
+
logger?: boolean;
|
|
47
|
+
}
|
|
1
48
|
/**
|
|
2
|
-
*
|
|
49
|
+
* Redige ricorsivamente token, segreti, cookie e header sensibili.
|
|
3
50
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
51
|
+
* Limita profondita, lunghezza delle stringhe e numero di elementi per evitare
|
|
52
|
+
* che un payload applicativo finisca per intero nell'audit.
|
|
53
|
+
*/
|
|
54
|
+
export declare function redactAccessiAuditValue(value: unknown, depth?: number): unknown;
|
|
55
|
+
/**
|
|
56
|
+
* Configura i sink di audit del processo.
|
|
57
|
+
*
|
|
58
|
+
* Chiamato da `AccessiModule.forRoot`. Le opzioni sono globali: un solo modulo
|
|
59
|
+
* Accessi per processo e la configurazione consigliata.
|
|
60
|
+
*/
|
|
61
|
+
export declare function configureAccessiAudit(options: AccessiAuditOptions | undefined): void;
|
|
62
|
+
/** Ripristina la configurazione iniziale (logger attivo, nessun sink). */
|
|
63
|
+
export declare function resetAccessiAudit(): void;
|
|
64
|
+
/** Sink interrogabile configurato, usato dagli endpoint amministrativi. */
|
|
65
|
+
export declare function getAccessiAuditStore(): AccessiAuditQueryableSink | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Registra un evento di sicurezza.
|
|
68
|
+
*
|
|
69
|
+
* Il record viene redatto prima di raggiungere logger e sink. Un sink guasto
|
|
70
|
+
* non interrompe mai il flusso applicativo.
|
|
6
71
|
*/
|
|
7
72
|
export declare function auditAccessi(event: string, details?: Record<string, unknown>): void;
|
|
@@ -1,14 +1,187 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.redactAccessiAuditValue = redactAccessiAuditValue;
|
|
4
|
+
exports.configureAccessiAudit = configureAccessiAudit;
|
|
5
|
+
exports.resetAccessiAudit = resetAccessiAudit;
|
|
6
|
+
exports.getAccessiAuditStore = getAccessiAuditStore;
|
|
3
7
|
exports.auditAccessi = auditAccessi;
|
|
4
8
|
const Logger_1 = require("../../Logger");
|
|
9
|
+
const metrics_1 = require("../observability/metrics");
|
|
10
|
+
const REDACTED = '[REDACTED]';
|
|
11
|
+
const TRUNCATED = '[TRUNCATED]';
|
|
12
|
+
const DEFAULT_REDACTED_KEYS = new Set([
|
|
13
|
+
'token',
|
|
14
|
+
'accesstoken',
|
|
15
|
+
'refreshtoken',
|
|
16
|
+
'idtoken',
|
|
17
|
+
'bearer',
|
|
18
|
+
'jwt',
|
|
19
|
+
'authorization',
|
|
20
|
+
'cookie',
|
|
21
|
+
'setcookie',
|
|
22
|
+
'password',
|
|
23
|
+
'passwordhash',
|
|
24
|
+
'hashedpassword',
|
|
25
|
+
'resettoken',
|
|
26
|
+
'secret',
|
|
27
|
+
'clientsecret',
|
|
28
|
+
'privatekey',
|
|
29
|
+
'apikey',
|
|
30
|
+
'csrf',
|
|
31
|
+
'csrftoken',
|
|
32
|
+
]);
|
|
33
|
+
const MAX_STRING_LENGTH = 512;
|
|
34
|
+
const MAX_ARRAY_LENGTH = 50;
|
|
35
|
+
const MAX_OBJECT_KEYS = 100;
|
|
36
|
+
const MAX_DEPTH = 4;
|
|
37
|
+
const PURGE_INTERVAL_MS = 60 * 60 * 1000;
|
|
38
|
+
let sinks = [];
|
|
39
|
+
let redactedKeys = new Set(DEFAULT_REDACTED_KEYS);
|
|
40
|
+
let retentionDays;
|
|
41
|
+
let loggerEnabled = true;
|
|
42
|
+
let lastPurgeAt = 0;
|
|
43
|
+
function normalizedKey(key) {
|
|
44
|
+
return key.toLowerCase().replace(/[-_\s]/g, '');
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Redige ricorsivamente token, segreti, cookie e header sensibili.
|
|
48
|
+
*
|
|
49
|
+
* Limita profondita, lunghezza delle stringhe e numero di elementi per evitare
|
|
50
|
+
* che un payload applicativo finisca per intero nell'audit.
|
|
51
|
+
*/
|
|
52
|
+
function redactAccessiAuditValue(value, depth = 0) {
|
|
53
|
+
if (depth > MAX_DEPTH)
|
|
54
|
+
return TRUNCATED;
|
|
55
|
+
if (value === null || value === undefined)
|
|
56
|
+
return value;
|
|
57
|
+
if (typeof value === 'string') {
|
|
58
|
+
return value.length > MAX_STRING_LENGTH ? `${value.slice(0, MAX_STRING_LENGTH - 3)}...` : value;
|
|
59
|
+
}
|
|
60
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
61
|
+
return value;
|
|
62
|
+
if (typeof value === 'bigint')
|
|
63
|
+
return value.toString();
|
|
64
|
+
if (value instanceof Date)
|
|
65
|
+
return value.toISOString();
|
|
66
|
+
if (value instanceof Error) {
|
|
67
|
+
return { name: value.name, message: redactAccessiAuditValue(value.message, depth + 1) };
|
|
68
|
+
}
|
|
69
|
+
if (Array.isArray(value)) {
|
|
70
|
+
return value.slice(0, MAX_ARRAY_LENGTH).map((item) => redactAccessiAuditValue(item, depth + 1));
|
|
71
|
+
}
|
|
72
|
+
if (typeof value === 'object') {
|
|
73
|
+
const result = {};
|
|
74
|
+
for (const [key, entry] of Object.entries(value).slice(0, MAX_OBJECT_KEYS)) {
|
|
75
|
+
result[key] = redactedKeys.has(normalizedKey(key))
|
|
76
|
+
? REDACTED
|
|
77
|
+
: redactAccessiAuditValue(entry, depth + 1);
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
return String(value);
|
|
82
|
+
}
|
|
83
|
+
function redactDetails(details) {
|
|
84
|
+
return redactAccessiAuditValue(details);
|
|
85
|
+
}
|
|
86
|
+
function reportSinkError(sink, error) {
|
|
87
|
+
var _a;
|
|
88
|
+
(0, metrics_1.recordAccessiMetric)('accessi_audit_sink_errors_total', 1, { sink: (_a = sink.name) !== null && _a !== void 0 ? _a : 'unknown' });
|
|
89
|
+
try {
|
|
90
|
+
new Logger_1.Logger('AccessiAudit').error(`Audit sink non disponibile${sink.name ? ` (${sink.name})` : ''}: ${error instanceof Error ? error.message : String(error)}`);
|
|
91
|
+
}
|
|
92
|
+
catch (_b) {
|
|
93
|
+
// Il logging non deve mai interrompere l'operazione applicativa.
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function writeToSink(sink, record) {
|
|
97
|
+
try {
|
|
98
|
+
const result = sink.write(record);
|
|
99
|
+
if (result && typeof result.catch === 'function') {
|
|
100
|
+
result.catch((error) => reportSinkError(sink, error));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
reportSinkError(sink, error);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function maybePurge() {
|
|
108
|
+
if (!retentionDays || retentionDays <= 0)
|
|
109
|
+
return;
|
|
110
|
+
const now = Date.now();
|
|
111
|
+
if (now - lastPurgeAt < PURGE_INTERVAL_MS)
|
|
112
|
+
return;
|
|
113
|
+
lastPurgeAt = now;
|
|
114
|
+
const before = new Date(now - retentionDays * 24 * 60 * 60 * 1000);
|
|
115
|
+
for (const sink of sinks) {
|
|
116
|
+
if (typeof sink.purge !== 'function')
|
|
117
|
+
continue;
|
|
118
|
+
try {
|
|
119
|
+
const result = sink.purge(before);
|
|
120
|
+
if (result && typeof result.catch === 'function') {
|
|
121
|
+
result.catch((error) => reportSinkError(sink, error));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
reportSinkError(sink, error);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Configura i sink di audit del processo.
|
|
131
|
+
*
|
|
132
|
+
* Chiamato da `AccessiModule.forRoot`. Le opzioni sono globali: un solo modulo
|
|
133
|
+
* Accessi per processo e la configurazione consigliata.
|
|
134
|
+
*/
|
|
135
|
+
function configureAccessiAudit(options) {
|
|
136
|
+
var _a, _b;
|
|
137
|
+
sinks = [];
|
|
138
|
+
redactedKeys = new Set(DEFAULT_REDACTED_KEYS);
|
|
139
|
+
retentionDays = undefined;
|
|
140
|
+
loggerEnabled = true;
|
|
141
|
+
lastPurgeAt = 0;
|
|
142
|
+
for (const key of (_a = options === null || options === void 0 ? void 0 : options.redact) !== null && _a !== void 0 ? _a : [])
|
|
143
|
+
redactedKeys.add(normalizedKey(key));
|
|
144
|
+
loggerEnabled = (options === null || options === void 0 ? void 0 : options.logger) !== false;
|
|
145
|
+
if ((options === null || options === void 0 ? void 0 : options.enabled) === false)
|
|
146
|
+
return;
|
|
147
|
+
if (options === null || options === void 0 ? void 0 : options.store)
|
|
148
|
+
sinks.push(options.store);
|
|
149
|
+
for (const sink of (_b = options === null || options === void 0 ? void 0 : options.sinks) !== null && _b !== void 0 ? _b : []) {
|
|
150
|
+
if (!sinks.includes(sink))
|
|
151
|
+
sinks.push(sink);
|
|
152
|
+
}
|
|
153
|
+
const days = Number(options === null || options === void 0 ? void 0 : options.retentionDays);
|
|
154
|
+
if (Number.isFinite(days) && days > 0)
|
|
155
|
+
retentionDays = days;
|
|
156
|
+
}
|
|
157
|
+
/** Ripristina la configurazione iniziale (logger attivo, nessun sink). */
|
|
158
|
+
function resetAccessiAudit() {
|
|
159
|
+
configureAccessiAudit(undefined);
|
|
160
|
+
}
|
|
161
|
+
/** Sink interrogabile configurato, usato dagli endpoint amministrativi. */
|
|
162
|
+
function getAccessiAuditStore() {
|
|
163
|
+
const configured = sinks.find((sink) => typeof sink.query === 'function'
|
|
164
|
+
&& typeof sink.purge === 'function');
|
|
165
|
+
return configured;
|
|
166
|
+
}
|
|
5
167
|
/**
|
|
6
|
-
*
|
|
168
|
+
* Registra un evento di sicurezza.
|
|
7
169
|
*
|
|
8
|
-
* Il
|
|
9
|
-
*
|
|
170
|
+
* Il record viene redatto prima di raggiungere logger e sink. Un sink guasto
|
|
171
|
+
* non interrompe mai il flusso applicativo.
|
|
10
172
|
*/
|
|
11
173
|
function auditAccessi(event, details = {}) {
|
|
12
|
-
|
|
174
|
+
const record = Object.assign({ event, timestamp: new Date().toISOString() }, redactDetails(details !== null && details !== void 0 ? details : {}));
|
|
175
|
+
if (loggerEnabled) {
|
|
176
|
+
try {
|
|
177
|
+
new Logger_1.Logger('AccessiAudit').warning(JSON.stringify(record));
|
|
178
|
+
}
|
|
179
|
+
catch (_a) {
|
|
180
|
+
// Il logging non deve mai interrompere l'operazione applicativa.
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
for (const sink of sinks)
|
|
184
|
+
writeToSink(sink, record);
|
|
185
|
+
maybePurge();
|
|
13
186
|
}
|
|
14
187
|
//# sourceMappingURL=audit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../../src/accessi-module/security/audit.ts"],"names":[],"mappings":";;AAQA,oCAQC;AAhBD,yCAAsC;AAEtC;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,KAAa,EAAE,UAAmC,EAAE;IAC/E,IAAI,eAAM,CAAC,cAAc,CAAC,CAAC,OAAO,CAChC,IAAI,CAAC,SAAS,iBACZ,KAAK,EACL,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,IAChC,OAAO,EACV,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { Logger } from '../../Logger';\n\n/**\n * Audit strutturato degli eventi di sicurezza Accessi.\n *\n * Il Logger redige gia campi come token, password, secret e authorization.\n * Non inserire mai payload completi o segreti nei dettagli.\n */\nexport function auditAccessi(event: string, details: Record<string, unknown> = {}): void {\n new Logger('AccessiAudit').warning(\n JSON.stringify({\n event,\n timestamp: new Date().toISOString(),\n ...details,\n }),\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../../src/accessi-module/security/audit.ts"],"names":[],"mappings":";;AAuGA,0DAyBC;AAqDD,sDAiBC;AAGD,8CAEC;AAGD,oDAMC;AAQD,oCAiBC;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EF,IAAI,aAAa,EAAE,CAAC;QAClB,IAAI,CAAC;YACH,IAAI,eAAM,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7D,CAAC;QAAC,WAAM,CAAC;YACP,iEAAiE;QACnE,CAAC;IACH,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACpD,UAAU,EAAE,CAAC;AACf,CAAC","sourcesContent":["import { Logger } from '../../Logger';\nimport { recordAccessiMetric } from '../observability/metrics';\n\n/** Record di audit normalizzato e gia redatto. */\nexport interface AccessiAuditRecord {\n event: string;\n timestamp: string;\n [key: string]: unknown;\n}\n\n/** Destinazione di un record di audit. */\nexport interface AccessiAuditSink {\n /** Nome usato nelle metriche di errore del sink. */\n name?: string;\n write(record: AccessiAuditRecord): void | Promise<void>;\n}\n\nexport interface AccessiAuditQuery {\n event?: string;\n from?: string;\n to?: string;\n codiceUtente?: number;\n limit?: number;\n offset?: number;\n order?: 'asc' | 'desc';\n}\n\nexport interface AccessiAuditPage {\n records: AccessiAuditRecord[];\n total: number;\n limit: number;\n offset: number;\n}\n\n/** Sink interrogabile dagli endpoint amministrativi e dalla retention. */\nexport interface AccessiAuditQueryableSink extends AccessiAuditSink {\n query(filter?: AccessiAuditQuery): Promise<AccessiAuditPage>;\n purge(before: Date): Promise<number>;\n}\n\n/** Opzioni di audit del modulo. */\nexport interface AccessiAuditOptions {\n /** `false` disattiva i sink ma lascia il log strutturato. Default: abilitati. */\n enabled?: boolean;\n /** Sink aggiuntivi (HTTP, DB, OpenTelemetry). */\n sinks?: AccessiAuditSink[];\n /** Sink interrogabile usato da `/api/accessi/audit`. Default: primo sink queryable. */\n store?: AccessiAuditQueryableSink;\n /** Giorni di retention applicati ai sink queryable. Default: nessuna scadenza automatica. */\n retentionDays?: number;\n /** Chiavi aggiuntive da redigere, oltre a quelle predefinite. */\n redact?: string[];\n /** Scrivi anche sul Logger strutturato. Default: true. */\n logger?: boolean;\n}\n\nconst REDACTED = '[REDACTED]';\nconst TRUNCATED = '[TRUNCATED]';\n\nconst DEFAULT_REDACTED_KEYS = new Set([\n 'token',\n 'accesstoken',\n 'refreshtoken',\n 'idtoken',\n 'bearer',\n 'jwt',\n 'authorization',\n 'cookie',\n 'setcookie',\n 'password',\n 'passwordhash',\n 'hashedpassword',\n 'resettoken',\n 'secret',\n 'clientsecret',\n 'privatekey',\n 'apikey',\n 'csrf',\n 'csrftoken',\n]);\n\nconst MAX_STRING_LENGTH = 512;\nconst MAX_ARRAY_LENGTH = 50;\nconst MAX_OBJECT_KEYS = 100;\nconst MAX_DEPTH = 4;\nconst PURGE_INTERVAL_MS = 60 * 60 * 1000;\n\nlet sinks: AccessiAuditSink[] = [];\nlet redactedKeys = new Set(DEFAULT_REDACTED_KEYS);\nlet retentionDays: number | undefined;\nlet loggerEnabled = true;\nlet lastPurgeAt = 0;\n\nfunction normalizedKey(key: string): string {\n return key.toLowerCase().replace(/[-_\\s]/g, '');\n}\n\n/**\n * Redige ricorsivamente token, segreti, cookie e header sensibili.\n *\n * Limita profondita, lunghezza delle stringhe e numero di elementi per evitare\n * che un payload applicativo finisca per intero nell'audit.\n */\nexport function redactAccessiAuditValue(value: unknown, depth = 0): unknown {\n if (depth > MAX_DEPTH) return TRUNCATED;\n if (value === null || value === undefined) return value;\n if (typeof value === 'string') {\n return value.length > MAX_STRING_LENGTH ? `${value.slice(0, MAX_STRING_LENGTH - 3)}...` : value;\n }\n if (typeof value === 'number' || typeof value === 'boolean') return value;\n if (typeof value === 'bigint') return value.toString();\n if (value instanceof Date) return value.toISOString();\n if (value instanceof Error) {\n return { name: value.name, message: redactAccessiAuditValue(value.message, depth + 1) };\n }\n if (Array.isArray(value)) {\n return value.slice(0, MAX_ARRAY_LENGTH).map((item) => redactAccessiAuditValue(item, depth + 1));\n }\n if (typeof value === 'object') {\n const result: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value as Record<string, unknown>).slice(0, MAX_OBJECT_KEYS)) {\n result[key] = redactedKeys.has(normalizedKey(key))\n ? REDACTED\n : redactAccessiAuditValue(entry, depth + 1);\n }\n return result;\n }\n return String(value);\n}\n\nfunction redactDetails(details: Record<string, unknown>): Record<string, unknown> {\n return redactAccessiAuditValue(details) as Record<string, unknown>;\n}\n\nfunction reportSinkError(sink: AccessiAuditSink, error: unknown): void {\n recordAccessiMetric('accessi_audit_sink_errors_total', 1, { sink: sink.name ?? 'unknown' });\n try {\n new Logger('AccessiAudit').error(\n `Audit sink non disponibile${sink.name ? ` (${sink.name})` : ''}: ${error instanceof Error ? error.message : String(error)}`,\n );\n } catch {\n // Il logging non deve mai interrompere l'operazione applicativa.\n }\n}\n\nfunction writeToSink(sink: AccessiAuditSink, record: AccessiAuditRecord): void {\n try {\n const result = sink.write(record);\n if (result && typeof (result as Promise<void>).catch === 'function') {\n (result as Promise<void>).catch((error) => reportSinkError(sink, error));\n }\n } catch (error) {\n reportSinkError(sink, error);\n }\n}\n\nfunction maybePurge(): void {\n if (!retentionDays || retentionDays <= 0) return;\n const now = Date.now();\n if (now - lastPurgeAt < PURGE_INTERVAL_MS) return;\n lastPurgeAt = now;\n const before = new Date(now - retentionDays * 24 * 60 * 60 * 1000);\n for (const sink of sinks) {\n if (typeof (sink as AccessiAuditQueryableSink).purge !== 'function') continue;\n try {\n const result = (sink as AccessiAuditQueryableSink).purge(before);\n if (result && typeof (result as Promise<number>).catch === 'function') {\n (result as Promise<number>).catch((error) => reportSinkError(sink, error));\n }\n } catch (error) {\n reportSinkError(sink, error);\n }\n }\n}\n\n/**\n * Configura i sink di audit del processo.\n *\n * Chiamato da `AccessiModule.forRoot`. Le opzioni sono globali: un solo modulo\n * Accessi per processo e la configurazione consigliata.\n */\nexport function configureAccessiAudit(options: AccessiAuditOptions | undefined): void {\n sinks = [];\n redactedKeys = new Set(DEFAULT_REDACTED_KEYS);\n retentionDays = undefined;\n loggerEnabled = true;\n lastPurgeAt = 0;\n\n for (const key of options?.redact ?? []) redactedKeys.add(normalizedKey(key));\n loggerEnabled = options?.logger !== false;\n if (options?.enabled === false) return;\n\n if (options?.store) sinks.push(options.store);\n for (const sink of options?.sinks ?? []) {\n if (!sinks.includes(sink)) sinks.push(sink);\n }\n const days = Number(options?.retentionDays);\n if (Number.isFinite(days) && days > 0) retentionDays = days;\n}\n\n/** Ripristina la configurazione iniziale (logger attivo, nessun sink). */\nexport function resetAccessiAudit(): void {\n configureAccessiAudit(undefined);\n}\n\n/** Sink interrogabile configurato, usato dagli endpoint amministrativi. */\nexport function getAccessiAuditStore(): AccessiAuditQueryableSink | undefined {\n const configured = sinks.find((sink): sink is AccessiAuditQueryableSink =>\n typeof (sink as AccessiAuditQueryableSink).query === 'function'\n && typeof (sink as AccessiAuditQueryableSink).purge === 'function',\n );\n return configured;\n}\n\n/**\n * Registra un evento di sicurezza.\n *\n * Il record viene redatto prima di raggiungere logger e sink. Un sink guasto\n * non interrompe mai il flusso applicativo.\n */\nexport function auditAccessi(event: string, details: Record<string, unknown> = {}): void {\n const record: AccessiAuditRecord = {\n event,\n timestamp: new Date().toISOString(),\n ...redactDetails(details ?? {}),\n };\n\n if (loggerEnabled) {\n try {\n new Logger('AccessiAudit').warning(JSON.stringify(record));\n } catch {\n // Il logging non deve mai interrompere l'operazione applicativa.\n }\n }\n\n for (const sink of sinks) writeToSink(sink, record);\n maybePurge();\n}\n"]}
|