M2 · Sistema e sicurezza #118

Merged
Alby96 merged 2 commits from feat/15-sistema-e-sicurezza into main 2026-11-11 15:56:09 +01:00
Owner

Milestone M2 (v0.2.0): l'istanza si avvia da sola dalle variabili KHAEMHAT_*, crea super utente e prima azienda, e si entra con password e verifica in due passaggi.

Cosa c'è

  • Avvio (#15): tutte le variabili sbagliate elencate insieme (uscita 2), varianti _FILE, migrazioni di sistema e aziende all'avvio, pagina "Avvio in corso" e /health/ready a 503 finché non è pronto.
  • Account e accesso (#16-#18): account di istanza e utenti aziendali, password PBKDF2 con storico e blocco, sessioni nel database (solo hash del token, rigenerato a ogni passo), TOTP con 10 codici di recupero, pagine di accesso (mockup 001-003), ruoli predefiniti, permessi con override, [RequirePermission] / [RequireLevel] / [RequireModule], audit di sicurezza a catena di hash, limite di 10 accessi al minuto per IP.
  • Licenze (#19): trial 60 giorni, .khl firmati ECDSA P-256, codici di attivazione, modalità test, limite di aziende e utenti, tools/Khaemhat.LicenseTool.
  • DataProtection, cache, log, attività (#20-#22): chiavi DataProtection nel DB cifrate; cache memoria o Redis con client RESP scritto in casa (ritorno alla memoria se Redis cade); log su sys_log per sezioni con X-Trace-Id; cron con fuso orario, lock, timeout, tentativi; job di pulizia sessioni, controllo licenza, retention log; storico dei record.
  • Aziende (#23): creazione e collegamento, stati, contesto azienda (X-Company), 503 in manutenzione.
  • Documentazione (#24): ADR 0019, wiki (Primi passi, Utenti e permessi, Licenze e moduli, Log, Istanza e database, Attività programmate), SECURITY, CHANGELOG 0.2.0, STATUS, DATA-MODEL rigenerato.

Verifica

  • Build Release con warning come errori: verde.
  • Test in locale: 180 verdi, 21 di PostgreSQL saltati (senza Docker): da verificare nel job PostgreSQL della CI.
  • Prova manuale su localhost: primo avvio, cambio password obbligatorio, attivazione TOTP, home, uscita, nessuna violazione CSP; job di sistema pianificati, log per sezioni.

Closes #15
Closes #16
Closes #17
Closes #18
Closes #19
Closes #20
Closes #21
Closes #22
Closes #23

🤖 Generated with Claude Code

Milestone M2 (v0.2.0): l'istanza si avvia da sola dalle variabili `KHAEMHAT_*`, crea super utente e prima azienda, e si entra con password e verifica in due passaggi. ## Cosa c'è - **Avvio** (#15): tutte le variabili sbagliate elencate insieme (uscita 2), varianti `_FILE`, migrazioni di sistema e aziende all'avvio, pagina "Avvio in corso" e `/health/ready` a 503 finché non è pronto. - **Account e accesso** (#16-#18): account di istanza e utenti aziendali, password PBKDF2 con storico e blocco, sessioni nel database (solo hash del token, rigenerato a ogni passo), TOTP con 10 codici di recupero, pagine di accesso (mockup 001-003), ruoli predefiniti, permessi con override, `[RequirePermission]` / `[RequireLevel]` / `[RequireModule]`, audit di sicurezza a catena di hash, limite di 10 accessi al minuto per IP. - **Licenze** (#19): trial 60 giorni, `.khl` firmati ECDSA P-256, codici di attivazione, modalità test, limite di aziende e utenti, `tools/Khaemhat.LicenseTool`. - **DataProtection, cache, log, attività** (#20-#22): chiavi DataProtection nel DB cifrate; cache memoria o Redis con client RESP scritto in casa (ritorno alla memoria se Redis cade); log su `sys_log` per sezioni con `X-Trace-Id`; cron con fuso orario, lock, timeout, tentativi; job di pulizia sessioni, controllo licenza, retention log; storico dei record. - **Aziende** (#23): creazione e collegamento, stati, contesto azienda (`X-Company`), 503 in manutenzione. - **Documentazione** (#24): ADR 0019, wiki (Primi passi, Utenti e permessi, Licenze e moduli, Log, Istanza e database, Attività programmate), SECURITY, CHANGELOG 0.2.0, STATUS, DATA-MODEL rigenerato. ## Verifica - Build Release con warning come errori: verde. - Test in locale: 180 verdi, 21 di PostgreSQL saltati (senza Docker): da verificare nel job PostgreSQL della CI. - Prova manuale su `localhost`: primo avvio, cambio password obbligatorio, attivazione TOTP, home, uscita, nessuna violazione CSP; job di sistema pianificati, log per sezioni. Closes #15 Closes #16 Closes #17 Closes #18 Closes #19 Closes #20 Closes #21 Closes #22 Closes #23 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Alby96 added 1 commit 2026-11-11 15:29:47 +01:00
feat: system and security - start-up, accounts, sign-in, licences, log, jobs, companies (M2)
CI / Build and test (SQLite) (pull_request) Successful in 55s
CI / PostgreSQL 16 integration (pull_request) Skipped
CI / PostgreSQL 17 integration (pull_request) Skipped
CI / YAML check (pull_request) Successful in 5s
CI / Docker image (pull_request) Failing after 2m4s
032c602b49
The instance now starts on its own from KHAEMHAT_* variables: it migrates the system
and company databases, creates the super user and the first company, and only then
reports ready. Users sign in with password and TOTP through revocable database
sessions, and licences decide which modules and how many companies are available.

- Configuration: every wrong variable reported at once (exit code 2), _FILE variants
- Accounts, password policy and lockout, TOTP with recovery codes, session states
  with token rotation, security audit with a hash chain
- Sign-in pages (mockups 001-003), authorization attributes, security headers and a
  CSP without inline scripts, login rate limit
- Signed licences, activation codes, test mode, licence tool
- DataProtection keys in the system database, encrypted with the instance key
- Memory or Redis cache (in-house RESP client) that falls back to memory
- Database log by section with trace id; cron scheduler with locks and system jobs;
  record history (audit_log)
- Company creation, states, company context and X-Company, 503 in maintenance
- In-memory SQLite databases stay alive for the process (tests, demo)
- Tests for all of the above, ADR 0019, wiki, SECURITY, CHANGELOG, STATUS, DATA-MODEL

Refs #15 #16 #17 #18 #19 #20 #21 #22 #23 #24

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Alby96 added 1 commit 2026-11-11 15:35:12 +01:00
ci: start the smoke-test containers with the variables M2 requires
CI / Build and test (SQLite) (pull_request) Successful in 59s
CI / PostgreSQL 16 integration (pull_request) Skipped
CI / PostgreSQL 17 integration (pull_request) Skipped
CI / YAML check (pull_request) Successful in 4s
CI / Docker image (pull_request) Successful in 1m20s
4502526f4d
Since M2 the instance refuses to start without a secret key, a super user and a
first company, and the home page redirects to the login. The CI and release smoke
tests now pass a throwaway key and test values, wait for /health/ready and check
the login page and its security headers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Alby96 merged commit 1c30054e3d into main 2026-11-11 15:56:09 +01:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: BalboSoft/Khaemhat#118