Files
slp-modular-cms/src/SlpModularCms.Modules.Contact/Config/ContactOptions.cs
T
SluijsensandClaude Sonnet 5.5 7748bbe9c9 Contactmodule: token- en inzendroute met spamafhandeling, idempotentie en retentietaak
Nieuwe module SlpModularCms.Modules.Contact met eigen DbContext en migratie InitialCreate. GET contact-messages/token en POST contact-messages zijn publiek ([PublicSiteEndpoint]), geven bij echte inzendingen, spam en herhalingen hetzelfde 202 en slaan spam apart op (30 dagen, dagplafond). Standaard staat de module uit (Contact:Enabled=false, 404 met lege body, geen databasetoegang) totdat de rate limiting per client op de basisbranch staat; de rate-limit-sleutel zit in een enkele functie zodat dat later een regel wijzigen is. Mail zit achter een seam (nog een no-op).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-10 13:07:27 +01:00

53 lines
2.0 KiB
C#

namespace SlpModularCms.Modules.Contact.Config;
/// <summary>
/// Per-host configuration of the contact module (section <c>Contact</c>).
/// </summary>
public class ContactOptions
{
public const string SectionName = "Contact";
/// <summary>
/// Master switch. While false the contact routes answer 404 and the module touches nothing.
/// It must only be switched on for a public host once per-client rate limiting is in place
/// (see <see cref="Services.ContactRateLimitPartition"/>).
/// </summary>
public bool Enabled { get; set; }
/// <summary>Identifies the site on stored rows and in the token purpose. Never taken from a request.</summary>
public string? SiteId { get; set; }
/// <summary>Minimum seconds between issuing the token and submitting; faster submissions are treated as spam.</summary>
public int MinSeconds { get; set; } = 3;
public int TokenLifetimeMinutes { get; set; } = 120;
/// <summary>Months a genuine message is kept (fixed per row at insert).</summary>
public int RetentionMonths { get; set; } = 12;
/// <summary>Days a message classified as spam is kept.</summary>
public int SpamRetentionDays { get; set; } = 30;
/// <summary>Per site and UTC day; beyond it spam is answered normally but not stored.</summary>
public int MaxSpamRowsPerDay { get; set; } = 200;
public int MaxBodyBytes { get; set; } = 16384;
/// <summary>Base of the validation problem <c>type</c> URI. When empty the type is <c>about:blank</c>.</summary>
public string? ProblemTypeBase { get; set; }
public ContactCaptchaOptions Captcha { get; set; } = new();
public string EffectiveSiteId => string.IsNullOrWhiteSpace(SiteId) ? "default" : SiteId.Trim();
}
public class ContactCaptchaOptions
{
public bool Enabled { get; set; }
public string? Provider { get; set; }
public string? SiteKey { get; set; }
/// <summary>Server-side secret; supply it through the environment or a secrets manager, never committed.</summary>
public string? Secret { get; set; }
}