emilsoftware-utilities 2.0.0-dev.36 → 2.0.0-dev.38
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-module/AccessiModule.d.ts +17 -1
- package/dist/accessi-module/AccessiModule.js +8 -4
- package/dist/accessi-module/AccessiModule.js.map +1 -1
- package/dist/accessi-module/Console/console.css +12 -0
- package/dist/accessi-module/Console/console.js +99 -5
- package/dist/accessi-module/Console/console.js.map +1 -1
- package/dist/accessi-module/Console/generated/accessiApi.d.ts +21 -1
- package/dist/accessi-module/Console/generated/accessiApi.js +19 -3
- package/dist/accessi-module/Console/generated/accessiApi.js.map +1 -1
- package/dist/accessi-module/Console/generated/model/bootstrapAdminRequest.d.ts +17 -0
- package/dist/accessi-module/Console/generated/model/bootstrapAdminRequest.js +9 -0
- package/dist/accessi-module/Console/generated/model/bootstrapAdminRequest.js.map +1 -0
- package/dist/accessi-module/Console/generated/model/bootstrapAdminResponse.d.ts +14 -0
- package/dist/accessi-module/Console/generated/model/bootstrapAdminResponse.js +3 -0
- package/dist/accessi-module/Console/generated/model/bootstrapAdminResponse.js.map +1 -0
- package/dist/accessi-module/Console/generated/model/bootstrapAdminResultDto.d.ts +13 -0
- package/dist/accessi-module/Console/generated/model/bootstrapAdminResultDto.js +9 -0
- package/dist/accessi-module/Console/generated/model/bootstrapAdminResultDto.js.map +1 -0
- package/dist/accessi-module/Console/generated/model/getSchemaResponse.d.ts +14 -0
- package/dist/accessi-module/Console/generated/model/getSchemaResponse.js +3 -0
- package/dist/accessi-module/Console/generated/model/getSchemaResponse.js.map +1 -0
- package/dist/accessi-module/Console/generated/model/index.d.ts +6 -0
- package/dist/accessi-module/Console/generated/model/index.js +6 -0
- package/dist/accessi-module/Console/generated/model/index.js.map +1 -1
- package/dist/accessi-module/Console/generated/model/schemaDdlResult.d.ts +20 -0
- package/dist/accessi-module/Console/generated/model/schemaDdlResult.js +3 -0
- package/dist/accessi-module/Console/generated/model/schemaDdlResult.js.map +1 -0
- package/dist/accessi-module/Console/generated/model/schemaDdlSection.d.ts +12 -0
- package/dist/accessi-module/Console/generated/model/schemaDdlSection.js +9 -0
- package/dist/accessi-module/Console/generated/model/schemaDdlSection.js.map +1 -0
- package/dist/accessi-module/Console/index.html +20 -0
- package/dist/accessi-module/Console/wiki.js +5 -0
- package/dist/accessi-module/Console/wiki.js.map +1 -1
- package/dist/accessi-module/Controllers/AuthController.d.ts +5 -2
- package/dist/accessi-module/Controllers/AuthController.js +39 -3
- package/dist/accessi-module/Controllers/AuthController.js.map +1 -1
- package/dist/accessi-module/Controllers/SchemaController.d.ts +9 -0
- package/dist/accessi-module/Controllers/SchemaController.js +79 -0
- package/dist/accessi-module/Controllers/SchemaController.js.map +1 -0
- package/dist/accessi-module/Dtos/AdminBootstrapDtos.d.ts +19 -0
- package/dist/accessi-module/Dtos/AdminBootstrapDtos.js +83 -0
- package/dist/accessi-module/Dtos/AdminBootstrapDtos.js.map +1 -0
- package/dist/accessi-module/Dtos/SchemaDtos.d.ts +19 -0
- package/dist/accessi-module/Dtos/SchemaDtos.js +84 -0
- package/dist/accessi-module/Dtos/SchemaDtos.js.map +1 -0
- package/dist/accessi-module/Dtos/index.d.ts +2 -0
- package/dist/accessi-module/Dtos/index.js +2 -0
- package/dist/accessi-module/Dtos/index.js.map +1 -1
- package/dist/accessi-module/Services/AdminBootstrapService/AdminBootstrapService.d.ts +33 -0
- package/dist/accessi-module/Services/AdminBootstrapService/AdminBootstrapService.js +106 -0
- package/dist/accessi-module/Services/AdminBootstrapService/AdminBootstrapService.js.map +1 -0
- package/dist/accessi-module/Services/SchemaExportService/SchemaExportService.d.ts +36 -0
- package/dist/accessi-module/Services/SchemaExportService/SchemaExportService.js +125 -0
- package/dist/accessi-module/Services/SchemaExportService/SchemaExportService.js.map +1 -0
- package/dist/accessi-module/index.d.ts +5 -0
- package/dist/accessi-module/index.js +12 -1
- package/dist/accessi-module/index.js.map +1 -1
- package/dist/accessi-module/security/adminBootstrap.d.ts +8 -0
- package/dist/accessi-module/security/adminBootstrap.js +41 -0
- package/dist/accessi-module/security/adminBootstrap.js.map +1 -0
- package/dist/accessi-module/security/publicAuthRateLimit.d.ts +1 -1
- package/dist/accessi-module/security/publicAuthRateLimit.js +1 -0
- package/dist/accessi-module/security/publicAuthRateLimit.js.map +1 -1
- package/dist/accessi-module/startupLog.d.ts +6 -0
- package/dist/accessi-module/startupLog.js +25 -0
- package/dist/accessi-module/startupLog.js.map +1 -0
- package/dist/emilsoftware-utilities-2.0.0-dev.38.tgz +0 -0
- package/dist/initEmilsoftwareModule.js +2 -0
- package/dist/initEmilsoftwareModule.js.map +1 -1
- package/package.json +1 -1
- package/dist/emilsoftware-utilities-2.0.0-dev.36.tgz +0 -0
|
@@ -56,6 +56,18 @@ export interface PublicAuthRateLimitOptions {
|
|
|
56
56
|
getUserByToken?: PublicAuthRateLimitRuleOptions;
|
|
57
57
|
twoFactorVerify?: PublicAuthRateLimitRuleOptions;
|
|
58
58
|
twoFactorResend?: PublicAuthRateLimitRuleOptions;
|
|
59
|
+
adminBootstrap?: PublicAuthRateLimitRuleOptions;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Bootstrap del primo admin. Se abilitato, Accessi genera un token casuale a ogni avvio del
|
|
63
|
+
* processo, lo stampa nel log e lo accetta sull'endpoint pubblico `POST /accessi/auth/bootstrap-admin`.
|
|
64
|
+
* Serve a creare il primo utente admin senza email di conferma e senza un admin gia esistente.
|
|
65
|
+
*/
|
|
66
|
+
export interface AdminBootstrapOptions {
|
|
67
|
+
/** Abilita il bootstrap admin. Default `false`. */
|
|
68
|
+
enabled?: boolean;
|
|
69
|
+
/** Crea l'utente come superutente oltre che admin. Default `true`. */
|
|
70
|
+
superUser?: boolean;
|
|
59
71
|
}
|
|
60
72
|
/** Controls the legacy public username/password registration endpoint. Disabled by default. */
|
|
61
73
|
export interface PublicRegistrationOptions {
|
|
@@ -119,7 +131,7 @@ export interface AccessiOptions {
|
|
|
119
131
|
/** Connessione Firebird alla base dati Accessi. */
|
|
120
132
|
databaseOptions: Options;
|
|
121
133
|
/**
|
|
122
|
-
* Basepath del sito es: 'http://www.il-mio-sito.it/nome-progetto(se c'
|
|
134
|
+
* Basepath del sito es: 'http://www.il-mio-sito.it/nome-progetto(se c'è)'
|
|
123
135
|
*/
|
|
124
136
|
confirmationEmailUrl: string;
|
|
125
137
|
/**
|
|
@@ -157,6 +169,10 @@ export interface AccessiOptions {
|
|
|
157
169
|
serviceTokens?: ServiceTokenOptions;
|
|
158
170
|
/** Catalog migrations applicative eseguite dopo la riconciliazione dello schema. */
|
|
159
171
|
catalogScripts?: CatalogScriptsOptions;
|
|
172
|
+
/** Bootstrap del primo admin tramite token casuale stampato a ogni avvio. */
|
|
173
|
+
adminBootstrap?: AdminBootstrapOptions;
|
|
174
|
+
/** Base URL pubblica usata solo per loggare gli indirizzi (console, swagger, API). */
|
|
175
|
+
publicBaseUrl?: string;
|
|
160
176
|
}
|
|
161
177
|
export declare class AccessiModule {
|
|
162
178
|
/**
|
|
@@ -31,6 +31,9 @@ const AccessiConsoleController_1 = require("./Controllers/AccessiConsoleControll
|
|
|
31
31
|
const ServiceTokenController_1 = require("./Controllers/ServiceTokenController");
|
|
32
32
|
const ServiceTokenService_1 = require("./Services/ServiceTokenService/ServiceTokenService");
|
|
33
33
|
const serviceTokenGuard_1 = require("./security/serviceTokenGuard");
|
|
34
|
+
const SchemaController_1 = require("./Controllers/SchemaController");
|
|
35
|
+
const SchemaExportService_1 = require("./Services/SchemaExportService/SchemaExportService");
|
|
36
|
+
const AdminBootstrapService_1 = require("./Services/AdminBootstrapService/AdminBootstrapService");
|
|
34
37
|
const emailConfiguration_1 = require("./security/emailConfiguration");
|
|
35
38
|
let AccessiModule = AccessiModule_1 = class AccessiModule {
|
|
36
39
|
/**
|
|
@@ -62,7 +65,7 @@ let AccessiModule = AccessiModule_1 = class AccessiModule {
|
|
|
62
65
|
AccessiDatabaseUpdater_1.AccessiDatabaseUpdater,
|
|
63
66
|
FederatedAuthService_1.FederatedAuthService,
|
|
64
67
|
ServiceTokenService_1.ServiceTokenService,
|
|
65
|
-
serviceTokenGuard_1.ServiceTokenGuard
|
|
68
|
+
serviceTokenGuard_1.ServiceTokenGuard, SchemaExportService_1.SchemaExportService, AdminBootstrapService_1.AdminBootstrapService
|
|
66
69
|
],
|
|
67
70
|
exports: [
|
|
68
71
|
'ACCESSI_OPTIONS',
|
|
@@ -76,7 +79,7 @@ let AccessiModule = AccessiModule_1 = class AccessiModule {
|
|
|
76
79
|
authenticateGen_1.AuthenticateGenService,
|
|
77
80
|
FederatedAuthService_1.FederatedAuthService,
|
|
78
81
|
ServiceTokenService_1.ServiceTokenService,
|
|
79
|
-
serviceTokenGuard_1.ServiceTokenGuard
|
|
82
|
+
serviceTokenGuard_1.ServiceTokenGuard, SchemaExportService_1.SchemaExportService, AdminBootstrapService_1.AdminBootstrapService
|
|
80
83
|
],
|
|
81
84
|
};
|
|
82
85
|
}
|
|
@@ -95,9 +98,10 @@ exports.AccessiModule = AccessiModule = AccessiModule_1 = __decorate([
|
|
|
95
98
|
FederatedAuthController_1.FederatedAuthController,
|
|
96
99
|
AccessiConsoleController_1.AccessiConsoleController,
|
|
97
100
|
ServiceTokenController_1.ServiceTokenController,
|
|
101
|
+
SchemaController_1.SchemaController,
|
|
98
102
|
],
|
|
99
|
-
providers: [AuthService_1.AuthService, TwoFactorService_1.TwoFactorService, UserService_1.UserService, EmailService_1.EmailService, PermissionService_1.PermissionService, FiltriService_1.FiltriService, ConfiguratorService_1.ConfiguratorService, jwt_strategy_1.JwtSimpleGuard, authenticateGen_1.AuthenticateGenService, AccessiDatabaseUpdater_1.AccessiDatabaseUpdater, FederatedAuthService_1.FederatedAuthService, ServiceTokenService_1.ServiceTokenService, serviceTokenGuard_1.ServiceTokenGuard],
|
|
100
|
-
exports: [AuthService_1.AuthService, UserService_1.UserService, EmailService_1.EmailService, PermissionService_1.PermissionService, FiltriService_1.FiltriService, ConfiguratorService_1.ConfiguratorService, jwt_strategy_1.JwtSimpleGuard, authenticateGen_1.AuthenticateGenService, FederatedAuthService_1.FederatedAuthService, ServiceTokenService_1.ServiceTokenService, serviceTokenGuard_1.ServiceTokenGuard],
|
|
103
|
+
providers: [AuthService_1.AuthService, TwoFactorService_1.TwoFactorService, UserService_1.UserService, EmailService_1.EmailService, PermissionService_1.PermissionService, FiltriService_1.FiltriService, ConfiguratorService_1.ConfiguratorService, jwt_strategy_1.JwtSimpleGuard, authenticateGen_1.AuthenticateGenService, AccessiDatabaseUpdater_1.AccessiDatabaseUpdater, FederatedAuthService_1.FederatedAuthService, ServiceTokenService_1.ServiceTokenService, serviceTokenGuard_1.ServiceTokenGuard, SchemaExportService_1.SchemaExportService, AdminBootstrapService_1.AdminBootstrapService],
|
|
104
|
+
exports: [AuthService_1.AuthService, UserService_1.UserService, EmailService_1.EmailService, PermissionService_1.PermissionService, FiltriService_1.FiltriService, ConfiguratorService_1.ConfiguratorService, jwt_strategy_1.JwtSimpleGuard, authenticateGen_1.AuthenticateGenService, FederatedAuthService_1.FederatedAuthService, ServiceTokenService_1.ServiceTokenService, serviceTokenGuard_1.ServiceTokenGuard, SchemaExportService_1.SchemaExportService, AdminBootstrapService_1.AdminBootstrapService],
|
|
101
105
|
})
|
|
102
106
|
], AccessiModule);
|
|
103
107
|
//# sourceMappingURL=AccessiModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessiModule.js","sourceRoot":"","sources":["../../src/accessi-module/AccessiModule.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,mFAAgF;AAQhF,2CAA+D;AAC/D,oEAAiE;AACjE,uEAAoE;AACpE,sFAAmF;AACnF,oEAAiE;AACjE,mEAAgE;AAChE,iEAA8D;AAC9D,6EAA0E;AAC1E,iEAA8D;AAC9D,0EAAuE;AACvE,qEAAkE;AAClE,iFAA8E;AAC9E,4FAAyF;AACzF,qDAAoD;AACpD,kEAAsE;AACtE,sFAAmF;AACnF,gFAA6E;AAC7E,sFAAmF;AACnF,qFAAkF;AAClF,iFAA8E;AAC9E,4FAAyF;AACzF,oEAAiE;AACjE,sEAAsE;AAqL/D,IAAM,aAAa,qBAAnB,MAAM,aAAa;IACxB;;;;;;OAMG;IACH,MAAM,CAAC,OAAO,CAAC,OAAuB;QACpC,yFAAyF;QACzF,IAAA,0CAAqB,EAAC,OAAO,CAAC,CAAC;QAC/B,OAAO;YACL,MAAM,EAAE,eAAa;YACrB,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,iBAAiB;oBAC1B,QAAQ,EAAE,OAAO;iBAClB;gBACD,yBAAW;gBACX,mCAAgB;gBAChB,yBAAW;gBACX,2BAAY;gBACZ,qCAAiB;gBACjB,6BAAa;gBACb,yCAAmB;gBACnB,6BAAc;gBACd,wCAAsB;gBACtB,+CAAsB;gBACtB,2CAAoB;gBACpB,yCAAmB;gBACnB,qCAAiB;aAClB;YACD,OAAO,EAAE;gBACP,iBAAiB;gBACjB,yBAAW;gBACX,yBAAW;gBACX,2BAAY;gBACZ,qCAAiB;gBACjB,6BAAa;gBACb,yCAAmB;gBACnB,6BAAc;gBACd,wCAAsB;gBACtB,2CAAoB;gBACpB,yCAAmB;gBACnB,qCAAiB;aAClB;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAhDY,sCAAa;wBAAb,aAAa;IAhBzB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,WAAW,EAAE;YACX,iCAAe;YACf,+BAAc;YACd,2CAAoB;YACpB,+BAAc;YACd,mCAAgB;YAChB,+CAAsB;YACtB,iDAAuB;YACvB,mDAAwB;YACxB,+CAAsB;SACvB;QACD,SAAS,EAAE,CAAC,yBAAW,EAAE,mCAAgB,EAAE,yBAAW,EAAE,2BAAY,EAAE,qCAAiB,EAAE,6BAAa,EAAE,yCAAmB,EAAE,6BAAc,EAAE,wCAAsB,EAAE,+CAAsB,EAAE,2CAAoB,EAAE,yCAAmB,EAAE,qCAAiB,CAAC;QAC1P,OAAO,EAAE,CAAC,yBAAW,EAAE,yBAAW,EAAE,2BAAY,EAAE,qCAAiB,EAAE,6BAAa,EAAE,yCAAmB,EAAE,6BAAc,EAAE,wCAAsB,EAAE,2CAAoB,EAAE,yCAAmB,EAAE,qCAAiB,CAAC;KAC/M,CAAC;GACW,aAAa,CAgDzB","sourcesContent":["import { TwoFactorService } from './Services/TwoFactorService/TwoFactorService';\n/**\n * Modulo che gestisce le operazioni di accesso degli utenti, incluse le rotte, il controller e il modello.\n *\n * @module AccessiModule\n * @author mttdev382\n */\nimport { Options } from 'node-firebird';\nimport { DynamicModule, Global, Module } from '@nestjs/common';\nimport { AuthService } from './Services/AuthService/AuthService';\nimport { EmailService } from './Services/EmailService/EmailService';\nimport { PermissionService } from './Services/PermissionService/PermissionService';\nimport { UserService } from './Services/UserService/UserService';\nimport { EmailController } from './Controllers/EmailController';\nimport { AuthController } from './Controllers/AuthController';\nimport { PermissionController } from './Controllers/PermissionController';\nimport { UserController } from './Controllers/UserController';\nimport { FiltriService } from './Services/FiltriService/FiltriService';\nimport { FiltriController } from './Controllers/FiltriController';\nimport { ConfiguratorController } from './Controllers/ConfiguratorController';\nimport { ConfiguratorService } from './Services/ConfiguratorService/ConfiguratorService';\nimport { JwtSimpleGuard } from './jwt/jwt.strategy';\nimport { AuthenticateGenService } from './middleware/authenticateGen';\nimport { AccessiDatabaseUpdater } from './database-updates/AccessiDatabaseUpdater';\nimport { FederatedAuthService } from './federated-auth/FederatedAuthService';\nimport { FederatedAuthController } from './federated-auth/FederatedAuthController';\nimport { AccessiConsoleController } from './Controllers/AccessiConsoleController';\nimport { ServiceTokenController } from './Controllers/ServiceTokenController';\nimport { ServiceTokenService } from './Services/ServiceTokenService/ServiceTokenService';\nimport { ServiceTokenGuard } from './security/serviceTokenGuard';\nimport { assertEmailConfigured } from './security/emailConfiguration';\n\n/** JWT emesso da Accessi dopo un login locale o SSO. Non riutilizzare il segreto del provider SSO. */\nexport interface JwtOptions {\n /** Segreto simmetrico per firmare e verificare i JWT Accessi; deve essere unico per ambiente. */\n secret: string;\n /** Durata compatibile con `jsonwebtoken`, per esempio `24h` o `3600s`. */\n expiresIn: string;\n}\n\n/** Parametri SMTP usati esclusivamente per impostazione e reset della password. */\nexport interface EmailOptions {\n host: string;\n port: number;\n secure: boolean;\n requireTLS : boolean;\n tls: {\n rejectUnauthorized: boolean,\n }\n from: string;\n auth: {\n user: string;\n pass: string;\n };\n}\n\n/** Configura campi applicativi aggiuntivi restituiti insieme al profilo Accessi. */\nexport interface ExtensionFieldsOptions {\n /** Connessione al database contenente la tabella estesa. */\n databaseOptions: Options;\n /** Chiave con cui i dati saranno esposti nella risposta. */\n objectKey: string;\n /** Tabella applicativa contenente i dati estesi. */\n tableName: string;\n /** Colonne consentite; non valorizzarle mai con input HTTP. */\n tableFields: string[];\n /** Colonna correlata a `UTENTI.CODUTE`. */\n tableJoinFieldName: string;\n}\n\n/** Limite per una singola categoria di endpoint pubblici. */\nexport interface PublicAuthRateLimitRuleOptions {\n windowMs: number;\n maxAttempts: number;\n}\n\n/** Protezione in-memory degli endpoint pubblici. In cluster aggiungere un limite anche al gateway. */\nexport interface PublicAuthRateLimitOptions {\n enabled?: boolean;\n login?: PublicAuthRateLimitRuleOptions;\n register?: PublicAuthRateLimitRuleOptions;\n passwordResetEmail?: PublicAuthRateLimitRuleOptions;\n passwordResetConfirm?: PublicAuthRateLimitRuleOptions;\n getUserByToken?: PublicAuthRateLimitRuleOptions;\n twoFactorVerify?: PublicAuthRateLimitRuleOptions;\n twoFactorResend?: PublicAuthRateLimitRuleOptions;\n}\n\n/** Controls the legacy public username/password registration endpoint. Disabled by default. */\nexport interface PublicRegistrationOptions {\n /** Enables POST /accessi/user/register. Applications that used it before must opt in explicitly. */\n enabled?: boolean;\n}\n\n/** Configurazione dei token di servizio (macchina-a-macchina, senza utente). */\nexport interface ServiceTokenOptions {\n /** Abilita gli endpoint amministrativi dei service token. Default `true`. */\n enabled?: boolean;\n /** Durata predefinita in giorni quando non e indicata una scadenza esplicita. Default: nessuna scadenza. */\n defaultTtlDays?: number;\n}\n\n/** Cosa fare quando uno script gia applicato presenta un checksum diverso (file modificato). */\nexport type CatalogScriptChecksumPolicy = 'error' | 'warn' | 'reapply';\n\n/**\n * Catalog migrations applicative (menu, ruoli, tipi, cataloghi). Gli script `.sql` vivono nel\n * backend ospitante (versionati in repository) e vengono eseguiti da Accessi dopo la\n * riconciliazione dello schema. Ogni script e tracciato nella tabella `ACCESSI_CATALOG_SCRIPT`,\n * quindi viene applicato una sola volta per database (idempotenza lato DB).\n */\nexport interface CatalogScriptsOptions {\n /** Abilita l'esecuzione automatica al bootstrap. Default `false`. */\n enabled?: boolean;\n /** Cartella contenente gli script `.sql` (assoluta o relativa alla working directory). */\n folder: string;\n /** Cosa fare se il checksum di uno script applicato e cambiato. Default `error`. */\n onChecksumMismatch?: CatalogScriptChecksumPolicy;\n /** Se `true` (default) un errore interrompe l'esecuzione e non avanza allo script successivo. */\n stopOnError?: boolean;\n /** Globi/estensioni inclusi. Default: tutti i `.sql`. */\n include?: string[];\n /** Numero massimo di script eseguiti in un singolo run (protezione operativa). Default: illimitato. */\n maxScriptsPerRun?: number;\n /**\n * Permette statement DDL/schema negli script. Default `false`: le catalog migrations possono\n * modificare solo righe. Sconsigliato: lo schema e di competenza di `db:update:accessi`.\n */\n allowDdl?: boolean;\n}\n\n/**\n * Enables Accessi's provider-agnostic federated identity capability.\n *\n * Accessi never validates Azure, Google, Apple, SAML, or other provider tokens.\n * The hosting backend must validate its own SSO flow and pass only a verified\n * `{ provider, subject }` identity to FederatedAuthService.\n */\nexport interface FederatedAuthenticationOptions {\n /** Attiva le API SSO generiche; con `false` il comportamento password storico rimane invariato. */\n enabled?: boolean;\n /** @deprecated Schema management is centralized in autoUpdateDatabase. This legacy flag no longer starts separate SSO migrations. */\n autoUpdateSchema?: boolean;\n /** Allows a backend to create a user from a verified external identity without a master user. Default false. */\n allowSelfRegistration?: boolean;\n}\n\n/**\n * Configurazione completa del modulo Accessi, fornita esclusivamente dal backend ospitante.\n * Segreti JWT, SMTP, database e le configurazioni tecniche dei provider SSO non devono mai raggiungere il browser.\n */\nexport interface AccessiOptions {\n /** Connessione Firebird alla base dati Accessi. */\n databaseOptions: Options;\n /**\n * Basepath del sito es: 'http://www.il-mio-sito.it/nome-progetto(se c'è)'\n */\n confirmationEmailUrl: string;\n /**\n * Percorso della pagina di reset personalizzata es. http://localhost:4200/#/admin/reset-password\n * N.B si sostituisce al confirmationMailURl\n */\n customResetPage?: string;\n /** URL di ritorno della pagina standard di reset dopo il completamento. */\n confirmationEmailReturnUrl: string;\n /** Prefisso applicativo facoltativo trasmesso alla pagina standard di reset. */\n confirmationEmailPrefix?: string;\n /** Chiave riservata alla compatibilita e alla migrazione delle password legacy cifrate. */\n encryptionKey: string;\n /** Abilita gli utenti fittizi `admin` e `demo` solo fuori produzione. */\n mockDemoUser: boolean;\n /** Attiva il controllo della scadenza password durante il login locale. */\n passwordExpiration?: boolean;\n /** Giorni di validita della password; quando assente Accessi usa 90 giorni. */\n passwordExpirationDays?: number;\n /** Esegue al bootstrap la conversione non distruttiva delle password legacy. Default `true`. */\n legacyPasswordMigrationOnStartup?: boolean;\n /** Riconcilia lo schema al bootstrap (default `true`). Con `false` verifica comunque la compatibilita in sola lettura e blocca avvii incompatibili. */\n autoUpdateDatabase?: boolean;\n /** Parametri JWT dei token emessi da Accessi. */\n jwtOptions: JwtOptions;\n /** Parametri SMTP per reset e attivazione password. */\n emailOptions: EmailOptions;\n publicAuthRateLimit?: PublicAuthRateLimitOptions;\n /** Public local registration is deliberately opt-in. Existing applications must set enabled: true to retain it. */\n publicRegistration?: PublicRegistrationOptions;\n /** Optional provider-agnostic SSO support. Provider-specific configuration remains in the hosting backend. */\n federatedAuthentication?: FederatedAuthenticationOptions;\n extensionFieldsOptions?: ExtensionFieldsOptions[];\n /** Token di servizio per chiamate tecniche macchina-a-macchina. Abilitati di default. */\n serviceTokens?: ServiceTokenOptions;\n /** Catalog migrations applicative eseguite dopo la riconciliazione dello schema. */\n catalogScripts?: CatalogScriptsOptions;\n}\n\n@Global()\n@Module({\n controllers: [\n EmailController,\n AuthController,\n PermissionController,\n UserController,\n FiltriController,\n ConfiguratorController,\n FederatedAuthController,\n AccessiConsoleController,\n ServiceTokenController,\n ],\n providers: [AuthService, TwoFactorService, UserService, EmailService, PermissionService, FiltriService, ConfiguratorService, JwtSimpleGuard, AuthenticateGenService, AccessiDatabaseUpdater, FederatedAuthService, ServiceTokenService, ServiceTokenGuard],\n exports: [AuthService, UserService, EmailService, PermissionService, FiltriService, ConfiguratorService, JwtSimpleGuard, AuthenticateGenService, FederatedAuthService, ServiceTokenService, ServiceTokenGuard],\n})\nexport class AccessiModule {\n /**\n * Registra Accessi nel contenitore Nest del backend ospitante.\n *\n * Usare questo metodo una sola volta nella composizione dell'applicazione. Per un backend\n * Express esistente usare invece `initializeAccessiModule`, che crea e monta l'host Nest interno.\n * La configurazione viene registrata con il token DI `ACCESSI_OPTIONS` ed e condivisa dai servizi.\n */\n static forRoot(options: AccessiOptions): DynamicModule {\n // Il servizio email e obbligatorio: reset password, 2FA e creazione utente ne dipendono.\n assertEmailConfigured(options);\n return {\n module: AccessiModule,\n providers: [\n {\n provide: 'ACCESSI_OPTIONS',\n useValue: options,\n },\n AuthService,\n TwoFactorService,\n UserService,\n EmailService,\n PermissionService,\n FiltriService,\n ConfiguratorService,\n JwtSimpleGuard,\n AuthenticateGenService,\n AccessiDatabaseUpdater,\n FederatedAuthService,\n ServiceTokenService,\n ServiceTokenGuard\n ],\n exports: [\n 'ACCESSI_OPTIONS',\n AuthService,\n UserService,\n EmailService,\n PermissionService,\n FiltriService,\n ConfiguratorService,\n JwtSimpleGuard,\n AuthenticateGenService,\n FederatedAuthService,\n ServiceTokenService,\n ServiceTokenGuard\n ],\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"AccessiModule.js","sourceRoot":"","sources":["../../src/accessi-module/AccessiModule.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,mFAAgF;AAQhF,2CAA+D;AAC/D,oEAAiE;AACjE,uEAAoE;AACpE,sFAAmF;AACnF,oEAAiE;AACjE,mEAAgE;AAChE,iEAA8D;AAC9D,6EAA0E;AAC1E,iEAA8D;AAC9D,0EAAuE;AACvE,qEAAkE;AAClE,iFAA8E;AAC9E,4FAAyF;AACzF,qDAAoD;AACpD,kEAAsE;AACtE,sFAAmF;AACnF,gFAA6E;AAC7E,sFAAmF;AACnF,qFAAkF;AAClF,iFAA8E;AAC9E,4FAAyF;AACzF,oEAAiE;AACjE,qEAAkE;AAClE,4FAAyF;AACzF,kGAA+F;AAC/F,sEAAsE;AAuM/D,IAAM,aAAa,qBAAnB,MAAM,aAAa;IACxB;;;;;;OAMG;IACH,MAAM,CAAC,OAAO,CAAC,OAAuB;QACpC,yFAAyF;QACzF,IAAA,0CAAqB,EAAC,OAAO,CAAC,CAAC;QAC/B,OAAO;YACL,MAAM,EAAE,eAAa;YACrB,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,iBAAiB;oBAC1B,QAAQ,EAAE,OAAO;iBAClB;gBACD,yBAAW;gBACX,mCAAgB;gBAChB,yBAAW;gBACX,2BAAY;gBACZ,qCAAiB;gBACjB,6BAAa;gBACb,yCAAmB;gBACnB,6BAAc;gBACd,wCAAsB;gBACtB,+CAAsB;gBACtB,2CAAoB;gBACpB,yCAAmB;gBACnB,qCAAiB,EAAE,yCAAmB,EAAE,6CAAqB;aAAC;YAChE,OAAO,EAAE;gBACP,iBAAiB;gBACjB,yBAAW;gBACX,yBAAW;gBACX,2BAAY;gBACZ,qCAAiB;gBACjB,6BAAa;gBACb,yCAAmB;gBACnB,6BAAc;gBACd,wCAAsB;gBACtB,2CAAoB;gBACpB,yCAAmB;gBACnB,qCAAiB,EAAE,yCAAmB,EAAE,6CAAqB;aAAC;SACjE,CAAC;IACJ,CAAC;CACF,CAAA;AA9CY,sCAAa;wBAAb,aAAa;IAjBzB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,WAAW,EAAE;YACX,iCAAe;YACf,+BAAc;YACd,2CAAoB;YACpB,+BAAc;YACd,mCAAgB;YAChB,+CAAsB;YACtB,iDAAuB;YACvB,mDAAwB;YACxB,+CAAsB;YACtB,mCAAgB;SACjB;QACD,SAAS,EAAE,CAAC,yBAAW,EAAE,mCAAgB,EAAE,yBAAW,EAAE,2BAAY,EAAE,qCAAiB,EAAE,6BAAa,EAAE,yCAAmB,EAAE,6BAAc,EAAE,wCAAsB,EAAE,+CAAsB,EAAE,2CAAoB,EAAE,yCAAmB,EAAE,qCAAiB,EAAE,yCAAmB,EAAE,6CAAqB,CAAC;QACtS,OAAO,EAAE,CAAC,yBAAW,EAAE,yBAAW,EAAE,2BAAY,EAAE,qCAAiB,EAAE,6BAAa,EAAE,yCAAmB,EAAE,6BAAc,EAAE,wCAAsB,EAAE,2CAAoB,EAAE,yCAAmB,EAAE,qCAAiB,EAAE,yCAAmB,EAAE,6CAAqB,CAAC;KAC3P,CAAC;GACW,aAAa,CA8CzB","sourcesContent":["import { TwoFactorService } from './Services/TwoFactorService/TwoFactorService';\n/**\n * Modulo che gestisce le operazioni di accesso degli utenti, incluse le rotte, il controller e il modello.\n *\n * @module AccessiModule\n * @author mttdev382\n */\nimport { Options } from 'node-firebird';\nimport { DynamicModule, Global, Module } from '@nestjs/common';\nimport { AuthService } from './Services/AuthService/AuthService';\nimport { EmailService } from './Services/EmailService/EmailService';\nimport { PermissionService } from './Services/PermissionService/PermissionService';\nimport { UserService } from './Services/UserService/UserService';\nimport { EmailController } from './Controllers/EmailController';\nimport { AuthController } from './Controllers/AuthController';\nimport { PermissionController } from './Controllers/PermissionController';\nimport { UserController } from './Controllers/UserController';\nimport { FiltriService } from './Services/FiltriService/FiltriService';\nimport { FiltriController } from './Controllers/FiltriController';\nimport { ConfiguratorController } from './Controllers/ConfiguratorController';\nimport { ConfiguratorService } from './Services/ConfiguratorService/ConfiguratorService';\nimport { JwtSimpleGuard } from './jwt/jwt.strategy';\nimport { AuthenticateGenService } from './middleware/authenticateGen';\nimport { AccessiDatabaseUpdater } from './database-updates/AccessiDatabaseUpdater';\nimport { FederatedAuthService } from './federated-auth/FederatedAuthService';\nimport { FederatedAuthController } from './federated-auth/FederatedAuthController';\nimport { AccessiConsoleController } from './Controllers/AccessiConsoleController';\nimport { ServiceTokenController } from './Controllers/ServiceTokenController';\nimport { ServiceTokenService } from './Services/ServiceTokenService/ServiceTokenService';\nimport { ServiceTokenGuard } from './security/serviceTokenGuard';\nimport { SchemaController } from './Controllers/SchemaController';\nimport { SchemaExportService } from './Services/SchemaExportService/SchemaExportService';\nimport { AdminBootstrapService } from './Services/AdminBootstrapService/AdminBootstrapService';\nimport { assertEmailConfigured } from './security/emailConfiguration';\n\n/** JWT emesso da Accessi dopo un login locale o SSO. Non riutilizzare il segreto del provider SSO. */\nexport interface JwtOptions {\n /** Segreto simmetrico per firmare e verificare i JWT Accessi; deve essere unico per ambiente. */\n secret: string;\n /** Durata compatibile con `jsonwebtoken`, per esempio `24h` o `3600s`. */\n expiresIn: string;\n}\n\n/** Parametri SMTP usati esclusivamente per impostazione e reset della password. */\nexport interface EmailOptions {\n host: string;\n port: number;\n secure: boolean;\n requireTLS : boolean;\n tls: {\n rejectUnauthorized: boolean,\n }\n from: string;\n auth: {\n user: string;\n pass: string;\n };\n}\n\n/** Configura campi applicativi aggiuntivi restituiti insieme al profilo Accessi. */\nexport interface ExtensionFieldsOptions {\n /** Connessione al database contenente la tabella estesa. */\n databaseOptions: Options;\n /** Chiave con cui i dati saranno esposti nella risposta. */\n objectKey: string;\n /** Tabella applicativa contenente i dati estesi. */\n tableName: string;\n /** Colonne consentite; non valorizzarle mai con input HTTP. */\n tableFields: string[];\n /** Colonna correlata a `UTENTI.CODUTE`. */\n tableJoinFieldName: string;\n}\n\n/** Limite per una singola categoria di endpoint pubblici. */\nexport interface PublicAuthRateLimitRuleOptions {\n windowMs: number;\n maxAttempts: number;\n}\n\n/** Protezione in-memory degli endpoint pubblici. In cluster aggiungere un limite anche al gateway. */\nexport interface PublicAuthRateLimitOptions {\n enabled?: boolean;\n login?: PublicAuthRateLimitRuleOptions;\n register?: PublicAuthRateLimitRuleOptions;\n passwordResetEmail?: PublicAuthRateLimitRuleOptions;\n passwordResetConfirm?: PublicAuthRateLimitRuleOptions;\n getUserByToken?: PublicAuthRateLimitRuleOptions;\n twoFactorVerify?: PublicAuthRateLimitRuleOptions;\n twoFactorResend?: PublicAuthRateLimitRuleOptions;\n adminBootstrap?: PublicAuthRateLimitRuleOptions;\n}\n\n/**\n * Bootstrap del primo admin. Se abilitato, Accessi genera un token casuale a ogni avvio del\n * processo, lo stampa nel log e lo accetta sull'endpoint pubblico `POST /accessi/auth/bootstrap-admin`.\n * Serve a creare il primo utente admin senza email di conferma e senza un admin gia esistente.\n */\nexport interface AdminBootstrapOptions {\n /** Abilita il bootstrap admin. Default `false`. */\n enabled?: boolean;\n /** Crea l'utente come superutente oltre che admin. Default `true`. */\n superUser?: boolean;\n}\n\n/** Controls the legacy public username/password registration endpoint. Disabled by default. */\nexport interface PublicRegistrationOptions {\n /** Enables POST /accessi/user/register. Applications that used it before must opt in explicitly. */\n enabled?: boolean;\n}\n\n/** Configurazione dei token di servizio (macchina-a-macchina, senza utente). */\nexport interface ServiceTokenOptions {\n /** Abilita gli endpoint amministrativi dei service token. Default `true`. */\n enabled?: boolean;\n /** Durata predefinita in giorni quando non e indicata una scadenza esplicita. Default: nessuna scadenza. */\n defaultTtlDays?: number;\n}\n\n/** Cosa fare quando uno script gia applicato presenta un checksum diverso (file modificato). */\nexport type CatalogScriptChecksumPolicy = 'error' | 'warn' | 'reapply';\n\n/**\n * Catalog migrations applicative (menu, ruoli, tipi, cataloghi). Gli script `.sql` vivono nel\n * backend ospitante (versionati in repository) e vengono eseguiti da Accessi dopo la\n * riconciliazione dello schema. Ogni script e tracciato nella tabella `ACCESSI_CATALOG_SCRIPT`,\n * quindi viene applicato una sola volta per database (idempotenza lato DB).\n */\nexport interface CatalogScriptsOptions {\n /** Abilita l'esecuzione automatica al bootstrap. Default `false`. */\n enabled?: boolean;\n /** Cartella contenente gli script `.sql` (assoluta o relativa alla working directory). */\n folder: string;\n /** Cosa fare se il checksum di uno script applicato e cambiato. Default `error`. */\n onChecksumMismatch?: CatalogScriptChecksumPolicy;\n /** Se `true` (default) un errore interrompe l'esecuzione e non avanza allo script successivo. */\n stopOnError?: boolean;\n /** Globi/estensioni inclusi. Default: tutti i `.sql`. */\n include?: string[];\n /** Numero massimo di script eseguiti in un singolo run (protezione operativa). Default: illimitato. */\n maxScriptsPerRun?: number;\n /**\n * Permette statement DDL/schema negli script. Default `false`: le catalog migrations possono\n * modificare solo righe. Sconsigliato: lo schema e di competenza di `db:update:accessi`.\n */\n allowDdl?: boolean;\n}\n\n/**\n * Enables Accessi's provider-agnostic federated identity capability.\n *\n * Accessi never validates Azure, Google, Apple, SAML, or other provider tokens.\n * The hosting backend must validate its own SSO flow and pass only a verified\n * `{ provider, subject }` identity to FederatedAuthService.\n */\nexport interface FederatedAuthenticationOptions {\n /** Attiva le API SSO generiche; con `false` il comportamento password storico rimane invariato. */\n enabled?: boolean;\n /** @deprecated Schema management is centralized in autoUpdateDatabase. This legacy flag no longer starts separate SSO migrations. */\n autoUpdateSchema?: boolean;\n /** Allows a backend to create a user from a verified external identity without a master user. Default false. */\n allowSelfRegistration?: boolean;\n}\n\n/**\n * Configurazione completa del modulo Accessi, fornita esclusivamente dal backend ospitante.\n * Segreti JWT, SMTP, database e le configurazioni tecniche dei provider SSO non devono mai raggiungere il browser.\n */\nexport interface AccessiOptions {\n /** Connessione Firebird alla base dati Accessi. */\n databaseOptions: Options;\n /**\n * Basepath del sito es: 'http://www.il-mio-sito.it/nome-progetto(se c'è)'\n */\n confirmationEmailUrl: string;\n /**\n * Percorso della pagina di reset personalizzata es. http://localhost:4200/#/admin/reset-password\n * N.B si sostituisce al confirmationMailURl\n */\n customResetPage?: string;\n /** URL di ritorno della pagina standard di reset dopo il completamento. */\n confirmationEmailReturnUrl: string;\n /** Prefisso applicativo facoltativo trasmesso alla pagina standard di reset. */\n confirmationEmailPrefix?: string;\n /** Chiave riservata alla compatibilita e alla migrazione delle password legacy cifrate. */\n encryptionKey: string;\n /** Abilita gli utenti fittizi `admin` e `demo` solo fuori produzione. */\n mockDemoUser: boolean;\n /** Attiva il controllo della scadenza password durante il login locale. */\n passwordExpiration?: boolean;\n /** Giorni di validita della password; quando assente Accessi usa 90 giorni. */\n passwordExpirationDays?: number;\n /** Esegue al bootstrap la conversione non distruttiva delle password legacy. Default `true`. */\n legacyPasswordMigrationOnStartup?: boolean;\n /** Riconcilia lo schema al bootstrap (default `true`). Con `false` verifica comunque la compatibilita in sola lettura e blocca avvii incompatibili. */\n autoUpdateDatabase?: boolean;\n /** Parametri JWT dei token emessi da Accessi. */\n jwtOptions: JwtOptions;\n /** Parametri SMTP per reset e attivazione password. */\n emailOptions: EmailOptions;\n publicAuthRateLimit?: PublicAuthRateLimitOptions;\n /** Public local registration is deliberately opt-in. Existing applications must set enabled: true to retain it. */\n publicRegistration?: PublicRegistrationOptions;\n /** Optional provider-agnostic SSO support. Provider-specific configuration remains in the hosting backend. */\n federatedAuthentication?: FederatedAuthenticationOptions;\n extensionFieldsOptions?: ExtensionFieldsOptions[];\n /** Token di servizio per chiamate tecniche macchina-a-macchina. Abilitati di default. */\n serviceTokens?: ServiceTokenOptions;\n /** Catalog migrations applicative eseguite dopo la riconciliazione dello schema. */\n catalogScripts?: CatalogScriptsOptions;\n /** Bootstrap del primo admin tramite token casuale stampato a ogni avvio. */\n adminBootstrap?: AdminBootstrapOptions;\n /** Base URL pubblica usata solo per loggare gli indirizzi (console, swagger, API). */\n publicBaseUrl?: string;\n}\n\n@Global()\n@Module({\n controllers: [\n EmailController,\n AuthController,\n PermissionController,\n UserController,\n FiltriController,\n ConfiguratorController,\n FederatedAuthController,\n AccessiConsoleController,\n ServiceTokenController,\n SchemaController,\n ],\n providers: [AuthService, TwoFactorService, UserService, EmailService, PermissionService, FiltriService, ConfiguratorService, JwtSimpleGuard, AuthenticateGenService, AccessiDatabaseUpdater, FederatedAuthService, ServiceTokenService, ServiceTokenGuard, SchemaExportService, AdminBootstrapService],\n exports: [AuthService, UserService, EmailService, PermissionService, FiltriService, ConfiguratorService, JwtSimpleGuard, AuthenticateGenService, FederatedAuthService, ServiceTokenService, ServiceTokenGuard, SchemaExportService, AdminBootstrapService],\n})\nexport class AccessiModule {\n /**\n * Registra Accessi nel contenitore Nest del backend ospitante.\n *\n * Usare questo metodo una sola volta nella composizione dell'applicazione. Per un backend\n * Express esistente usare invece `initializeAccessiModule`, che crea e monta l'host Nest interno.\n * La configurazione viene registrata con il token DI `ACCESSI_OPTIONS` ed e condivisa dai servizi.\n */\n static forRoot(options: AccessiOptions): DynamicModule {\n // Il servizio email e obbligatorio: reset password, 2FA e creazione utente ne dipendono.\n assertEmailConfigured(options);\n return {\n module: AccessiModule,\n providers: [\n {\n provide: 'ACCESSI_OPTIONS',\n useValue: options,\n },\n AuthService,\n TwoFactorService,\n UserService,\n EmailService,\n PermissionService,\n FiltriService,\n ConfiguratorService,\n JwtSimpleGuard,\n AuthenticateGenService,\n AccessiDatabaseUpdater,\n FederatedAuthService,\n ServiceTokenService,\n ServiceTokenGuard, SchemaExportService, AdminBootstrapService],\n exports: [\n 'ACCESSI_OPTIONS',\n AuthService,\n UserService,\n EmailService,\n PermissionService,\n FiltriService,\n ConfiguratorService,\n JwtSimpleGuard,\n AuthenticateGenService,\n FederatedAuthService,\n ServiceTokenService,\n ServiceTokenGuard, SchemaExportService, AdminBootstrapService],\n };\n }\n}\n"]}
|
|
@@ -626,3 +626,15 @@ article h3 { margin-bottom: var(--s2); }
|
|
|
626
626
|
.markdown-body code { padding: 1px 5px; border-radius: var(--r-sm); color: var(--brand-strong); background: var(--brand-soft); font-family: var(--font-mono); font-size: .92em; }
|
|
627
627
|
.markdown-code { margin: 0; padding: var(--s4); overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
|
|
628
628
|
.markdown-code code { padding: 0; background: transparent; color: var(--ink); white-space: pre; }
|
|
629
|
+
|
|
630
|
+
/* Sezione SQL / schema */
|
|
631
|
+
.entity-summary { display: flex; flex-wrap: wrap; gap: var(--s3); padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-sunken); }
|
|
632
|
+
.entity-summary strong { color: var(--brand-strong); }
|
|
633
|
+
.sql-section { display: grid; gap: var(--s2); min-width: 0; }
|
|
634
|
+
.sql-section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
|
|
635
|
+
.sql-section-head h3 { margin: 0; color: var(--ink); }
|
|
636
|
+
|
|
637
|
+
/* Bootstrap admin (schermata di login) */
|
|
638
|
+
.bootstrap-admin { margin-top: var(--s4); padding: var(--s3); border: 1px dashed var(--line); border-radius: var(--r-md); background: var(--surface-sunken); }
|
|
639
|
+
.bootstrap-admin summary { cursor: pointer; font-weight: 650; color: var(--ink-2); }
|
|
640
|
+
.bootstrap-admin form { display: grid; gap: var(--s2); margin-top: var(--s3); }
|
|
@@ -95,6 +95,21 @@ var resendTwoFactor = async (resendTwoFactorRequest, options) => {
|
|
|
95
95
|
}
|
|
96
96
|
);
|
|
97
97
|
};
|
|
98
|
+
var getBootstrapAdminUrl = () => {
|
|
99
|
+
return `/api/accessi/auth/bootstrap-admin`;
|
|
100
|
+
};
|
|
101
|
+
var bootstrapAdmin = async (bootstrapAdminRequest, options) => {
|
|
102
|
+
return accessiFetch(
|
|
103
|
+
getBootstrapAdminUrl(),
|
|
104
|
+
{
|
|
105
|
+
...options,
|
|
106
|
+
method: "POST",
|
|
107
|
+
body: JSON.stringify(
|
|
108
|
+
bootstrapAdminRequest
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
};
|
|
98
113
|
var getGetRolesUrl = () => {
|
|
99
114
|
return `/api/accessi/permission/roles`;
|
|
100
115
|
};
|
|
@@ -727,6 +742,18 @@ var rotateServiceToken = async (tokenId, options) => {
|
|
|
727
742
|
}
|
|
728
743
|
);
|
|
729
744
|
};
|
|
745
|
+
var getGetSchemaUrl = () => {
|
|
746
|
+
return `/api/accessi/schema`;
|
|
747
|
+
};
|
|
748
|
+
var getSchema = async (options) => {
|
|
749
|
+
return accessiFetch(
|
|
750
|
+
getGetSchemaUrl(),
|
|
751
|
+
{
|
|
752
|
+
...options,
|
|
753
|
+
method: "GET"
|
|
754
|
+
}
|
|
755
|
+
);
|
|
756
|
+
};
|
|
730
757
|
|
|
731
758
|
// src/accessi-module/Console/wiki.ts
|
|
732
759
|
var p = (text) => ({ kind: "p", text });
|
|
@@ -868,7 +895,9 @@ var WIKI_SECTIONS = [
|
|
|
868
895
|
["federatedAuthentication", "FederatedAuthenticationOptions", "no", `Abilita l'SSO generico.`],
|
|
869
896
|
["extensionFieldsOptions", "ExtensionFieldsOptions[]", "no", "Tabelle esterne allegate al profilo."],
|
|
870
897
|
["serviceTokens", "{ enabled, defaultTtlDays }", "no", "Token macchina-a-macchina, abilitati per impostazione predefinita."],
|
|
871
|
-
["catalogScripts", "{ enabled, folder, ... }", "no", "Catalog migrations SQL eseguite dopo la riconciliazione dello schema."]
|
|
898
|
+
["catalogScripts", "{ enabled, folder, ... }", "no", "Catalog migrations SQL eseguite dopo la riconciliazione dello schema."],
|
|
899
|
+
["adminBootstrap", "{ enabled, superUser }", "no", "Token casuale a ogni avvio per creare il primo admin dalla console."],
|
|
900
|
+
["publicBaseUrl", "string", "no", "Base URL usata solo per loggare console/swagger/API."]
|
|
872
901
|
]
|
|
873
902
|
),
|
|
874
903
|
good("ts", [
|
|
@@ -1358,11 +1387,13 @@ POST /api/accessi/auth/confirm-reset-password/{token}
|
|
|
1358
1387
|
`Filtri: filtri utente e tipi filtro.`,
|
|
1359
1388
|
`Token di servizio: creazione, rotazione, revoca.`,
|
|
1360
1389
|
`SSO: provider e identit\xE0.`,
|
|
1361
|
-
`Wiki e Changelog: documentazione e novit\xE0 della libreria
|
|
1390
|
+
`Wiki e Changelog: documentazione e novit\xE0 della libreria.`,
|
|
1391
|
+
`SQL: esporta il DDL delle entit\xE0 Accessi (tabelle, generatori, FK, indici, check, trigger) per replicare il database.`
|
|
1362
1392
|
]),
|
|
1363
1393
|
note("info", `Superutente (FLGSUPER)`, `Riceve TUTTE le abilitazioni al livello massimo (30) dopo il login. In console vede solo la sezione Utenti e gestisce utenti, ruoli e grant.`),
|
|
1364
1394
|
note("info", `Admin (FLGADMIN)`, `Accede a tutta la console (catalogo, token, SSO, utenti) ma NON conferisce abilitazioni: i menu restano quelli assegnati via ABILITAZIONI/RUOLI_MNU.`),
|
|
1365
|
-
note("info", `Accesso`, `Apri /api/accessi/console e accedi con un utente con FLGSUPER o FLGADMIN. Le sezioni sono raggiungibili anche tramite deep link (per esempio /api/accessi/console/menu-e-gruppi/menu).`)
|
|
1395
|
+
note("info", `Accesso`, `Apri /api/accessi/console e accedi con un utente con FLGSUPER o FLGADMIN. Le sezioni sono raggiungibili anche tramite deep link (per esempio /api/accessi/console/menu-e-gruppi/menu).`),
|
|
1396
|
+
note("info", `Bootstrap admin`, `Con adminBootstrap.enabled il backend stampa a ogni avvio un token casuale (monouso, valido fino al riavvio). Nella schermata di login della console trovi "Crea utente admin": incolla il token e crea il primo admin senza email di conferma. La password \xE8 opzionale: se assente viene generata e mostrata una sola volta.`)
|
|
1366
1397
|
]
|
|
1367
1398
|
},
|
|
1368
1399
|
// -------------------------------------------------------------------------
|
|
@@ -1418,6 +1449,7 @@ POST /api/accessi/auth/confirm-reset-password/{token}
|
|
|
1418
1449
|
["Filtri", "GET filtri/tipi, POST/PUT/DELETE filtri/tipi[/:tipFil], GET/POST filtri/utente"],
|
|
1419
1450
|
["SSO", "GET/POST federated-auth/providers, PATCH/DELETE providers/:provider, GET/POST users/:codiceUtente/identities, POST users, PATCH users/:codiceUtente/password-login"],
|
|
1420
1451
|
["Token", "POST/GET service-token, DELETE service-token/:tokenId, POST service-token/:tokenId/rotate"],
|
|
1452
|
+
["Schema", "GET schema (DDL completo + entit\xE0 presenti, solo admin)"],
|
|
1421
1453
|
["Console", "GET console, console/:view, console/:view/:sub, console/assets/:file"]
|
|
1422
1454
|
]
|
|
1423
1455
|
)
|
|
@@ -1875,7 +1907,8 @@ var routeSegment = {
|
|
|
1875
1907
|
ssoUsers: "sso/utenti",
|
|
1876
1908
|
tokens: "token-di-servizio",
|
|
1877
1909
|
wiki: "wiki",
|
|
1878
|
-
changelog: "changelog"
|
|
1910
|
+
changelog: "changelog",
|
|
1911
|
+
sql: "sql"
|
|
1879
1912
|
};
|
|
1880
1913
|
var routeView = Object.fromEntries(Object.entries(routeSegment).map(([view, segment]) => [segment, view]));
|
|
1881
1914
|
var parentDefaultView = {
|
|
@@ -3124,6 +3157,41 @@ async function showChangelog() {
|
|
|
3124
3157
|
${renderMarkdown(changelog_default)}
|
|
3125
3158
|
</article></div>`);
|
|
3126
3159
|
}
|
|
3160
|
+
function downloadTextFile(fileName, content) {
|
|
3161
|
+
const blob = new Blob([content], { type: "text/plain;charset=utf-8" });
|
|
3162
|
+
const url = URL.createObjectURL(blob);
|
|
3163
|
+
const anchor = document.createElement("a");
|
|
3164
|
+
anchor.href = url;
|
|
3165
|
+
anchor.download = fileName;
|
|
3166
|
+
document.body.appendChild(anchor);
|
|
3167
|
+
anchor.click();
|
|
3168
|
+
anchor.remove();
|
|
3169
|
+
URL.revokeObjectURL(url);
|
|
3170
|
+
}
|
|
3171
|
+
async function showSql() {
|
|
3172
|
+
const schema = result(await getSchema());
|
|
3173
|
+
const copy = (text, notice) => () => handleAction(async () => {
|
|
3174
|
+
await navigator.clipboard.writeText(text);
|
|
3175
|
+
showNotice(notice);
|
|
3176
|
+
});
|
|
3177
|
+
render(`<div class="toolbar"><button id="sql-copy-all">Copia tutto</button><button id="sql-download" class="secondary">Scarica .sql</button><button id="sql-reload" class="secondary">Aggiorna</button></div>
|
|
3178
|
+
<h2>SQL dello schema</h2>
|
|
3179
|
+
<p class="form-help">DDL generato dallo schema Accessi <strong>${escapeHtml(schema.version)}</strong>. Usalo per creare le entita su una nuova installazione (database vuoto).</p>
|
|
3180
|
+
<div class="entity-summary">
|
|
3181
|
+
<span><strong>${schema.presentTables.length}</strong> tabelle presenti</span>
|
|
3182
|
+
<span><strong>${schema.presentGenerators.length}</strong> generatori</span>
|
|
3183
|
+
<span><strong>${schema.extraTables.length}</strong> tabelle extra fuori schema Accessi</span>
|
|
3184
|
+
</div>
|
|
3185
|
+
${schema.extraTables.length ? `<p class="form-help">Tabelle presenti non gestite da Accessi: <code>${schema.extraTables.map((name) => escapeHtml(name)).join(", ")}</code></p>` : ""}
|
|
3186
|
+
${schema.sections.map((section) => `<section class="sql-section"><div class="sql-section-head"><h3>${escapeHtml(section.title)}</h3><button type="button" class="secondary" data-sql-copy="${escapeHtml(section.id)}">Copia sezione</button></div><pre class="markdown-code"><code>${escapeHtml(section.sql)}</code></pre></section>`).join("")}`);
|
|
3187
|
+
byId("sql-copy-all").onclick = copy(schema.script, "Script SQL completo copiato.");
|
|
3188
|
+
byId("sql-download").onclick = () => downloadTextFile(`accessi-schema-${schema.version}.sql`, schema.script);
|
|
3189
|
+
byId("sql-reload").onclick = () => handleAction(showSql);
|
|
3190
|
+
document.querySelectorAll("[data-sql-copy]").forEach((button) => {
|
|
3191
|
+
const section = schema.sections.find((entry) => entry.id === button.dataset.sqlCopy);
|
|
3192
|
+
if (section) button.onclick = copy(section.sql, `Sezione "${section.title}" copiata.`);
|
|
3193
|
+
});
|
|
3194
|
+
}
|
|
3127
3195
|
async function show(view) {
|
|
3128
3196
|
try {
|
|
3129
3197
|
showNotice("");
|
|
@@ -3139,7 +3207,8 @@ async function show(view) {
|
|
|
3139
3207
|
ssoUsers: showSsoUsers,
|
|
3140
3208
|
tokens: showServiceTokens,
|
|
3141
3209
|
wiki: showWiki,
|
|
3142
|
-
changelog: showChangelog
|
|
3210
|
+
changelog: showChangelog,
|
|
3211
|
+
sql: showSql
|
|
3143
3212
|
};
|
|
3144
3213
|
setActiveNavigation(view);
|
|
3145
3214
|
const renderView = views[view];
|
|
@@ -3153,6 +3222,31 @@ async function show(view) {
|
|
|
3153
3222
|
var loginForm = document.getElementById("login-form");
|
|
3154
3223
|
if (loginForm) loginForm.onsubmit = loginView;
|
|
3155
3224
|
byId("restart-login").onclick = resetLogin;
|
|
3225
|
+
var bootstrapAdminForm = document.getElementById("bootstrap-admin-form");
|
|
3226
|
+
if (bootstrapAdminForm) {
|
|
3227
|
+
bootstrapAdminForm.onsubmit = async (event) => {
|
|
3228
|
+
event.preventDefault();
|
|
3229
|
+
const status = document.getElementById("bootstrap-admin-status");
|
|
3230
|
+
try {
|
|
3231
|
+
if (status) status.textContent = "";
|
|
3232
|
+
const values = formValues(bootstrapAdminForm);
|
|
3233
|
+
const fields = new FormData(bootstrapAdminForm);
|
|
3234
|
+
const created = result(await bootstrapAdmin({
|
|
3235
|
+
token: values.token ?? "",
|
|
3236
|
+
email: values.email ?? "",
|
|
3237
|
+
nome: values.nome || void 0,
|
|
3238
|
+
cognome: values.cognome || void 0,
|
|
3239
|
+
password: values.password || void 0,
|
|
3240
|
+
superUser: fields.has("superUser")
|
|
3241
|
+
}));
|
|
3242
|
+
const generated = created.password ? ` Password generata (copiala ora): ${created.password}` : "";
|
|
3243
|
+
if (status) status.textContent = `Utente admin creato: ${created.email}.${generated} Ora accedi dal form principale.`;
|
|
3244
|
+
bootstrapAdminForm.reset();
|
|
3245
|
+
} catch (error) {
|
|
3246
|
+
if (status) status.textContent = error instanceof Error ? error.message : "Creazione non riuscita.";
|
|
3247
|
+
}
|
|
3248
|
+
};
|
|
3249
|
+
}
|
|
3156
3250
|
byId("two-factor-form").onsubmit = async (event) => {
|
|
3157
3251
|
event.preventDefault();
|
|
3158
3252
|
if (!pendingChallenge) return;
|