Server reale e veste Docker (M5): composizione, collegamento, vista remota, salute, immagine e modello Unraid

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
Claude committed 2026-10-13 20:17:22 +00:00
1 parent 0515776b04
commit 550c220cd4
35 files changed
+6124 -10

No files matched your search

+39 -1
View File
@@ -14,6 +14,13 @@ public sealed class SecurityMiddleware(RequestDelegate next, FebeWebOptions opti
public static readonly IReadOnlyList<string> PublicPrefixes =
["/accesso", "/api/accesso", "/css/", "/caratteri/", "/img/", "/testi/", "/js/", "/favicon.ico"];
/// <summary>
/// Without a password (FEBE_PASSWORD missing) only these answer, so that the interface can show the page that
/// explains the problem (spec §11): the application page, its files, the capabilities with the problems, the
/// preferences (theme). Everything else, the remote view first, gets 503.
/// </summary>
public static readonly IReadOnlyList<string> WithoutPasswordApi = ["/api/capabilities", "/api/preferences"];
public async Task InvokeAsync(HttpContext context)
{
ArgumentNullException.ThrowIfNull(context);
@@ -21,6 +28,13 @@ public sealed class SecurityMiddleware(RequestDelegate next, FebeWebOptions opti
var response = context.Response;
SetHeaders(response);
// The Docker health check: no session, any Host (it comes from inside the container), «ok» or «problema» only.
if (Connection.HealthEndpoint.IsHealthRequest(request))
{
await next(context).ConfigureAwait(false);
return;
}
if (!HostOriginGuard.HostAllowed(request, options))
{
await RefuseAsync(context, StatusCodes.Status400BadRequest, "Indirizzo non ammesso: apri Febe dal suo indirizzo.").ConfigureAwait(false);
@@ -99,13 +113,18 @@ public sealed class SecurityMiddleware(RequestDelegate next, FebeWebOptions opti
private async Task<bool> PasswordAsync(HttpContext context)
{
var path = context.Request.Path.Value ?? "/";
if (passwords is null)
{
if (OpenWithoutPassword(context.Request, path))
{
return true;
}
await RefuseAsync(context, StatusCodes.Status503ServiceUnavailable, "Manca la password dell'interfaccia (FEBE_PASSWORD): Febe non si apre senza.").ConfigureAwait(false);
return false;
}
var path = context.Request.Path.Value ?? "/";
if (PublicPrefixes.Any(p => path.StartsWith(p, StringComparison.OrdinalIgnoreCase)))
{
return true;
@@ -130,6 +149,25 @@ public sealed class SecurityMiddleware(RequestDelegate next, FebeWebOptions opti
private static bool IsApi(HttpRequest request) => request.Path.StartsWithSegments("/api", StringComparison.OrdinalIgnoreCase);
/// <summary>What may be read without a password: the error page and what it needs, never a command.</summary>
private static bool OpenWithoutPassword(HttpRequest request, string path)
{
if (!HttpMethods.IsGet(request.Method) && !HttpMethods.IsHead(request.Method))
{
return false;
}
if (IsApi(request))
{
return WithoutPasswordApi.Any(a => string.Equals(path, a, StringComparison.OrdinalIgnoreCase));
}
// Interface files, and page addresses (no extension) that answer with the application page.
return PublicPrefixes.Any(p => path.StartsWith(p, StringComparison.OrdinalIgnoreCase))
|| path.StartsWith("/icone/", StringComparison.OrdinalIgnoreCase)
|| !Path.HasExtension(path);
}
private static async Task RefuseAsync(HttpContext context, int status, string message)
{
context.Response.StatusCode = status;