feat(server): API v1 with auth, uploads, sync, jobs, render nodes and events
- Security: PBKDF2-SHA512 (210,000 iterations) hashes, opaque bearer tokens stored as SHA-256 with sliding expiry and revocation, HttpOnly/Secure/ SameSite=Strict admin cookie with a session-bound CSRF token, sign-in rate limit and lockout, role/permission metadata on every endpoint, audit log, first-run administrator bootstrap. - Sequences with keyset paging, ETags and settings_version conflicts; sync manifest; frames, proxies, thumbnails and exports streamed with Range. - Chunked resumable uploads with hash short-circuit, quota and disk checks, staging on the archive volume, SHA-256 verification and IArchiveIngest. - Job engine host, jobs API, render nodes with heartbeat timeout and reassignment, WebSocket events, LAN discovery beacon, upload cleanup. - Windows service host over advapi32 (--service, --install-service, --uninstall-service); fails fast without the archive module services. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
56 files changed
+4726
-108
No files matched your search
@@ -0,0 +1,41 @@
|
||||
using Titano.Data;
|
||||
using Titano.Server.Configuration;
|
||||
|
||||
namespace Titano.Server.Hosting;
|
||||
|
||||
/// <summary>Opens and migrates the server database at startup (BRIEF §6.1), waiting for a PostgreSQL container that is still starting.</summary>
|
||||
public static class ServerDatabase
|
||||
{
|
||||
private const int Attempts = 10;
|
||||
private static readonly TimeSpan RetryDelay = TimeSpan.FromSeconds(3);
|
||||
|
||||
public static async Task<TitanoDatabase> OpenAsync(ServerOptions options, ILogger logger, CancellationToken cancellationToken)
|
||||
{
|
||||
var settings = options.ToDatabaseOptions();
|
||||
for (var attempt = 1; ; attempt++)
|
||||
{
|
||||
try
|
||||
{
|
||||
var db = await TitanoDatabase.OpenAsync(settings, cancellationToken).ConfigureAwait(false);
|
||||
logger.LogInformation("Database {Dialect} ready, schema version {Version}", db.Dialect, db.SchemaVersion);
|
||||
return db;
|
||||
}
|
||||
catch (DatabaseConnectionException ex) when (attempt < Attempts)
|
||||
{
|
||||
logger.LogWarning("Database not reachable yet ({Reason}); retry {Attempt} of {Attempts} in {Delay} s",
|
||||
ex.Message, attempt, Attempts - 1, RetryDelay.TotalSeconds);
|
||||
await Task.Delay(RetryDelay, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Engine and version, e.g. "PostgreSQL 17.2" or "SQLite 3.45.1".</summary>
|
||||
public static async Task<string> DescribeAsync(TitanoDatabase db, CancellationToken cancellationToken)
|
||||
{
|
||||
await using var session = await db.Database.OpenAsync(cancellationToken).ConfigureAwait(false);
|
||||
var postgres = db.Dialect == Dialect.Postgres;
|
||||
var version = await session.ScalarAsync<string>(postgres ? "SHOW server_version" : "SELECT sqlite_version()", [], cancellationToken).ConfigureAwait(false);
|
||||
var number = version?.Split(' ', 2)[0] ?? string.Empty;
|
||||
return (postgres ? "PostgreSQL " : "SQLite ") + number;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user