feat(server): web server, interface shell, demo mode and Docker image (refs #11 #12 #13 #14 #15 #16 #17)
Phase 1 completed on top of the library foundations: - Server: startup state machine (config, first run, database down, schema, identity, ready) with an error page that retries by itself; the configured database is the only one ever opened, and a vanished SQLite file is never recreated. REST API and status WebSocket; session cookie auth, CSRF on every form and write call; desktop and demo answer only the computer itself. - Interface: static Blazor rendering with plain forms (no interactive runtime), menu, top bar and phone bottom bar as in the mockups, light and dark themes with appendix C tokens and a contrast test, Panoramica, Diario, Rischio, Impostazioni; service pages for sign-in, first access, desktop first run and the database error page with its choices. - Demo mode (tasks seed-demo): appendix F in a database of its own under the temp folder, frozen clock, never touches the configured installation. - Docker: entrypoint gives /data to PUID:PGID and drops root with setpriv, HEALTHCHECK through bash /dev/tcp; proven with SQLite, PostgreSQL, a wrong configuration and a database that goes away and comes back. - tasks screenshots drives the installed Edge/Chrome through DevTools for exact 1440 and 390 pixel shots; anubis db export|import on the command line. Fixes from the independent review: return paths without control characters, Host check against DNS rebinding, attempt limit counted before the check and also on the error-page password, one-use TOTP codes and a code to switch the second factor off, error-page choices serialized with the startup loop, identity checked before migrating, restore restarts with "Ferma tutto" on, damaged archives reported instead of crashing. Running the server tests on PostgreSQL exposed pages rendered before their data arrived; data-loading components now load first (LoadedComponent). Decisions in ADR 0007. Tests: 100 on SQLite and on PostgreSQL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
53ca01b7c3
commit
f9d71559e8
71 files changed
+5853
-80
No files matched your search
@@ -0,0 +1,79 @@
|
||||
@page "/primo-avvio"
|
||||
@layout ServiceLayout
|
||||
@attribute [AllowAnonymous]
|
||||
@inject AnubisHost Host
|
||||
|
||||
<PageTitle>Primo avvio · Anubis</PageTitle>
|
||||
|
||||
<h1>Primo avvio</h1>
|
||||
@if (!_local)
|
||||
{
|
||||
<p class="notice notice-attention" role="alert"><Icon Name="lock" Size="16" />La prima configurazione si fa solo dal computer su cui gira Anubis.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>Due passi: dove tenere i dati e la password per entrare. Conti, capitale e Telegram si aggiungono dopo, dalle Impostazioni.</p>
|
||||
@if (Message is { } message)
|
||||
{
|
||||
<p class="notice notice-loss" role="alert"><Icon Name="alert" Size="16" />@message</p>
|
||||
}
|
||||
|
||||
<form method="post" action="/azioni/primo-avvio" class="form" data-wizard>
|
||||
<AntiforgeryToken />
|
||||
@if (!Host.Config.IsComplete)
|
||||
{
|
||||
<fieldset class="service-section">
|
||||
<legend><span class="step">1</span>Database</legend>
|
||||
<label class="choice">
|
||||
<input type="radio" name="motore" value="sqlite" checked data-engine />
|
||||
<span><strong>SQLite</strong> (consigliato): un file nella cartella dei dati, niente da installare.</span>
|
||||
</label>
|
||||
<label class="choice">
|
||||
<input type="radio" name="motore" value="postgres" data-engine />
|
||||
<span><strong>PostgreSQL</strong>: un server che hai già, con un database dedicato e vuoto.</span>
|
||||
</label>
|
||||
<div class="postgres-fields" data-postgres>
|
||||
<label for="host">Indirizzo del server</label>
|
||||
<input id="host" name="host" autocomplete="off" placeholder="192.168.1.10" />
|
||||
<div class="row">
|
||||
<div><label for="porta">Porta</label><input id="porta" name="porta" inputmode="numeric" value="5432" /></div>
|
||||
<div><label for="nome">Nome del database</label><input id="nome" name="nome" value="anubis" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div><label for="utente">Utente</label><input id="utente" name="utente" value="anubis" autocomplete="off" /></div>
|
||||
<div><label for="dbpassword">Password del database</label><input id="dbpassword" name="dbpassword" type="password" autocomplete="off" /></div>
|
||||
</div>
|
||||
<p class="hint">La password del database non va in <code>config.toml</code>: la custodisce Windows per il tuo utente.</p>
|
||||
<button class="btn" type="submit" formaction="/azioni/primo-avvio/prova" data-test-connection>Prova la connessione</button>
|
||||
<p class="test-result" data-test-result role="status"></p>
|
||||
</div>
|
||||
</fieldset>
|
||||
}
|
||||
<fieldset class="service-section">
|
||||
<legend><span class="step">@(Host.Config.IsComplete ? "1" : "2")</span>Password</legend>
|
||||
<p class="hint">Serve per entrare nell'interfaccia, anche da questo computer. Almeno @Passwords.MinimumLength caratteri.</p>
|
||||
<label for="password">Password</label>
|
||||
<input id="password" name="password" type="password" autocomplete="new-password" minlength="@Passwords.MinimumLength" required />
|
||||
<label for="conferma">Scrivila di nuovo</label>
|
||||
<input id="conferma" name="conferma" type="password" autocomplete="new-password" minlength="@Passwords.MinimumLength" required />
|
||||
</fieldset>
|
||||
<p class="hint">Anubis lavora solo quando il computer è acceso. Dopo un'assenza ricostruisce cosa è successo prima di riprendere.</p>
|
||||
<button class="btn btn-primary" type="submit">Crea l'installazione</button>
|
||||
</form>
|
||||
}
|
||||
|
||||
@code {
|
||||
private bool _local;
|
||||
|
||||
[CascadingParameter]
|
||||
public HttpContext? HttpContext { get; set; }
|
||||
|
||||
[SupplyParameterFromQuery(Name = "errore")]
|
||||
public string? Errore { get; set; }
|
||||
|
||||
protected override void OnInitialized() => _local = HttpContext is not null && CurrentUser.IsLocal(HttpContext);
|
||||
|
||||
private string? Message => Errore == "database"
|
||||
? "Non riesco a collegarmi al database con questi dati. Controlla indirizzo, porta, nome, utente e password, poi riprova."
|
||||
: PasswordMessages.For(Errore);
|
||||
}
|
||||
Reference in new issue
Block a user