Sessione salvata cifrata, copiata a «Ho finito» (#36, S4)
Il client del sito ha bisogno della sessione del browser di Febe: ora la copia c'è, cifrata e dietro un interruttore, senza cambiare nulla di predefinito. - Opzione «raccolta» (pagine predefinita, richieste): solo con «richieste» e almeno un'operazione configurata si costruiscono sessione salvata, client del sito e copia. Con Instagram nulla cambia: le dieci operazioni restano non configurate (mancano __spin_*, __req, __s, __dyn, __csr e altri). - Cookie con dominio, percorso, solo-host, Secure, HttpOnly e scadenza, mandati solo dove il browser li manderebbe (RFC 6265). - Sezione «page» del catalogo: dove la pagina tiene ogni valore; nuovi campi rev, hs, hsi, dpr, ccg, comet_req, entry_nonce. Il caricatore rifiuta un'operazione configurata con un valore di sessione senza fonte nella pagina. - Dati/sessione/sessione.json: DPAPI su Windows, AES-256-GCM in Docker (chiave da FEBE_CHIAVE_SESSIONE o chiave.bin), scrittura atomica, file illeggibile = nessuna sessione. «Scollega» la cancella; chiave.bin resta. - Copia a «Ho finito» con Network.getCookies e una sola Runtime.evaluate in sola lettura, solo da una pagina del sito e finché dura il permesso di guida. - FEBE_PASSWORD e FEBE_CHIAVE_SESSIONE non passano a Chromium, Xvfb, ffmpeg. - Sito di prova: csrftoken, cookie limitato a /api/, registro di moduli suo. - Revisione su tre lenti: 11 punti confermati, tutti corretti. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3046b2da47
commit
c87768766c
69 files changed
+5936
-415
No files matched your search
@@ -3,14 +3,16 @@ using System.Net;
|
||||
using Febe.App;
|
||||
using Febe.Browser.Hosting;
|
||||
using Febe.Browser.Recipes;
|
||||
using Febe.Core.Security;
|
||||
using Febe.Web;
|
||||
|
||||
namespace Febe.Server;
|
||||
|
||||
/// <summary>
|
||||
/// Configuration of the real server (spec §11): environment variables of the container, plus a few command-line
|
||||
/// options for development (other folders, the local test site, a short first-session delay). The password comes only
|
||||
/// from the environment, never from the command line (which other users of the machine can read).
|
||||
/// options for development (other folders, the local test site, a short first-session delay). The password and the key
|
||||
/// of the saved session come only from the environment, never from the command line (which other users of the machine
|
||||
/// can read), and never appear in <see cref="ToString"/>, in <see cref="Warnings"/> or in a problem.
|
||||
/// </summary>
|
||||
internal sealed record ServerOptions
|
||||
{
|
||||
@@ -25,6 +27,22 @@ internal sealed record ServerOptions
|
||||
/// <summary>FEBE_PASSWORD: the interface password. Mandatory; never logged or shown.</summary>
|
||||
public string? Password { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// FEBE_CHIAVE_SESSIONE, decoded (issue #36, S4, spec §13.2): the 32-byte AES key of the saved session, kept out of
|
||||
/// the Data folder. Null when the variable is not set (the key is then <c>Dati/sessione/chiave.bin</c>) or is not a
|
||||
/// key (<see cref="SessionKeyProblem"/>). Never logged or shown.
|
||||
/// </summary>
|
||||
public byte[]? SessionKey { get; init; }
|
||||
|
||||
/// <summary>What is wrong with FEBE_CHIAVE_SESSIONE (its format only, never its value); null when it is right or unset.</summary>
|
||||
public string? SessionKeyProblem { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Option «raccolta» (<c>--raccolta</c>, FEBE_RACCOLTA; the command line wins): by the pages (default) or by requests
|
||||
/// (issue #36, S4).
|
||||
/// </summary>
|
||||
public CollectionRoute Collection { get; init; } = CollectionRoute.Pages;
|
||||
|
||||
/// <summary>Where Kestrel listens: every address in Docker (the port is published), 127.0.0.1 with <c>--ascolta</c>.</summary>
|
||||
public IPAddress ListenAddress { get; init; } = IPAddress.Any;
|
||||
|
||||
@@ -115,6 +133,7 @@ internal sealed record ServerOptions
|
||||
TestSite = TestSite,
|
||||
TestSiteAutoLogin = TestSiteAutoLogin,
|
||||
FirstSessionDelay = FirstSessionDelay,
|
||||
Collection = Collection,
|
||||
Warnings = Warnings,
|
||||
};
|
||||
|
||||
@@ -188,9 +207,28 @@ internal sealed record ServerOptions
|
||||
return false;
|
||||
}
|
||||
|
||||
var collection = CollectionRoute.Pages;
|
||||
if (Env(CollectionRouteNames.EnvironmentVariable) is { } collectionText && !CollectionRouteNames.TryParse(collectionText, out collection))
|
||||
{
|
||||
problem = CollectionRouteNames.Problem(CollectionRouteNames.EnvironmentVariable, collectionText);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Raw, like the password: the value never reaches a warning, a problem or the log.
|
||||
byte[]? sessionKey = null;
|
||||
string? sessionKeyProblem = null;
|
||||
if (environment(Core.Security.SessionKey.EnvironmentVariable) is { Length: > 0 } keyText
|
||||
&& !Core.Security.SessionKey.TryParse(keyText, out sessionKey, out sessionKeyProblem))
|
||||
{
|
||||
sessionKey = null;
|
||||
}
|
||||
|
||||
options = options with
|
||||
{
|
||||
Password = environment("FEBE_PASSWORD") is { Length: > 0 } password ? password : null,
|
||||
Password = environment(ChildProcessEnvironment.PasswordVariable) is { Length: > 0 } password ? password : null,
|
||||
SessionKey = sessionKey,
|
||||
SessionKeyProblem = sessionKeyProblem,
|
||||
Collection = collection,
|
||||
Port = port,
|
||||
ZoneId = zoneId,
|
||||
Zone = zone,
|
||||
@@ -286,6 +324,19 @@ internal sealed record ServerOptions
|
||||
case "--accesso-di-prova":
|
||||
options = options with { TestSiteAutoLogin = true };
|
||||
break;
|
||||
case CollectionRouteNames.Option:
|
||||
{
|
||||
var text = Next();
|
||||
if (!CollectionRouteNames.TryParse(text, out var route))
|
||||
{
|
||||
problem = CollectionRouteNames.Problem(CollectionRouteNames.Option, text);
|
||||
return false;
|
||||
}
|
||||
|
||||
options = options with { Collection = route };
|
||||
break;
|
||||
}
|
||||
|
||||
case "--prima-sessione":
|
||||
{
|
||||
var text = Next();
|
||||
@@ -339,6 +390,19 @@ internal sealed record ServerOptions
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// What the options are, for a debugger or an exception: the secrets only as «impostata» or «assente», never their
|
||||
/// value (the generated text of a record would print them).
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
var password = string.IsNullOrEmpty(Password) ? "assente" : "impostata";
|
||||
var key = SessionKey is not null ? "impostata" : SessionKeyProblem is not null ? "non valida" : "assente";
|
||||
return string.Create(
|
||||
CultureInfo.InvariantCulture,
|
||||
$"ServerOptions {{ Dati = {DataFolder}, Libreria = {LibraryFolder}, Porta = {Port}, Sito = {Site.Name}, Raccolta = {CollectionRouteNames.Name(Collection)}, {ChildProcessEnvironment.PasswordVariable} = {password}, {Core.Security.SessionKey.EnvironmentVariable} = {key} }}");
|
||||
}
|
||||
|
||||
/// <summary>The time zone named by TZ, or null when unknown.</summary>
|
||||
public static TimeZoneInfo? FindZone(string id) =>
|
||||
TimeZoneInfo.TryFindSystemTimeZoneById(id, out var zone) ? zone : null;
|
||||
|
||||
Reference in new issue
Block a user