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

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>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-11 15:29:24 +01:00
1 parent 4582837b70
commit 032c602b49
107 files changed
+12202 -116

No files matched your search

+51
View File
@@ -29,3 +29,54 @@ body { font-family: var(--kh-font); font-size: 13px; background: var(--kh-bg); -
#blazor-error-ui { background: #FADEDC; color: #1E2733; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
display: none; left: 0; padding: .6rem 1.25rem .7rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
/* Sign-in pages (mockups 001-003): brand panel on the left, form card on the right. */
.kh-auth { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 52%) 1fr; color: #1E2733; }
.kh-auth .brand { display: flex; flex-direction: column; justify-content: space-between; padding: 48px 44px 36px; color: #E8EDF5;
background: radial-gradient(1100px 620px at 15% 0%, #243A5E 0%, #17243A 55%, #0F1826 100%); }
.kh-auth .brand .mark { border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
.kh-auth .brand h2 { font-size: 30px; letter-spacing: -.5px; margin: 18px 0 10px; font-weight: 650; }
.kh-auth .brand p { max-width: 460px; color: #B8C5DA; font-size: 14px; line-height: 1.5; margin: 0; }
.kh-auth .features { list-style: none; margin: 32px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kh-auth .features li { padding: 10px 12px; border-radius: 8px; font-size: 11.5px; color: #B8C5DA; line-height: 1.4;
background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .09); }
.kh-auth .features strong { display: block; color: #E8EDF5; font-weight: 600; margin-bottom: 2px; }
.kh-auth .panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 24px; background: var(--kh-bg); }
.kh-auth .card { width: 100%; max-width: 380px; }
.kh-auth h1 { font-size: 20px; margin: 0 0 4px; font-weight: 650; }
.kh-auth .sub { color: #5B6776; margin: 0 0 18px; line-height: 1.45; }
.kh-auth footer { margin-top: 28px; font-size: 11.5px; color: #8A95A3; }
.kh-auth footer a { color: #1F5FA8; text-decoration: none; }
.kh-form { display: flex; flex-direction: column; gap: 4px; }
.kh-form label { font-size: 11.5px; font-weight: 600; color: #5B6776; margin-top: 8px; }
.kh-form input[type=text], .kh-form input[type=password], .kh-form input:not([type]), .kh-form select {
height: 32px; padding: 0 10px; border: 1px solid #C5CDD7; border-radius: 6px; background: #FFF; font: inherit; color: inherit; }
.kh-form input:focus, .kh-form select:focus { outline: 2px solid #1F5FA8; outline-offset: -1px; border-color: #1F5FA8; }
.kh-form .check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: #1E2733; margin-top: 12px; }
.kh-form .otp { height: 44px; font-size: 22px; letter-spacing: 8px; text-align: center; font-variant-numeric: tabular-nums; }
.kh-form .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.kh-form .row .kh-btn { margin-top: 0; }
.kh-form .hint { font-size: 11.5px; color: #8A95A3; }
.kh-btn { display: inline-flex; align-items: center; justify-content: center; height: 32px; padding: 0 14px; margin-top: 16px; border-radius: 6px;
border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.kh-btn.primary { background: #1F5FA8; color: #FFF; align-self: flex-start; }
.kh-btn.primary:hover { background: #174A85; }
.kh-btn.ghost { background: transparent; color: #F0C86A; border-color: rgba(240, 200, 106, .5); }
.kh-alert { padding: 10px 12px; border-radius: 6px; margin: 12px 0; line-height: 1.45; font-size: 12.5px; }
.kh-alert.err { background: #FADEDC; color: #9E362D; }
.kh-alert.warn { background: #FBEFD9; color: #8B5511; margin-top: 20px; }
.kh-alert.info { background: #E3ECF8; color: #174A85; margin-top: 20px; }
.kh-rules { margin: 10px 0 0; padding-left: 18px; color: #5B6776; font-size: 11.5px; line-height: 1.6; }
.kh-secret { margin: 0 0 6px; }
.kh-secret dt { font-size: 11.5px; font-weight: 600; color: #5B6776; margin-top: 8px; }
.kh-secret dd { margin: 4px 0 0; }
.kh-secret code { font-size: 15px; letter-spacing: 1px; word-break: break-all; }
.kh-codes { list-style: none; padding: 0; margin: 0 0 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.kh-codes code { display: block; padding: 6px 8px; background: #FFF; border: 1px solid #DDE3EA; border-radius: 6px; text-align: center; font-size: 14px; }
@media (max-width: 760px) {
.kh-auth { grid-template-columns: 1fr; }
.kh-auth .brand { padding: 24px; }
.kh-auth .features { display: none; }
}