Bifrost/src/Bifrost.Web/Configuration/RegistrationOptions.cs
Heimdall e67257c750 Budget registration per address; embed difficulty; expiry queue; 404 on empty withdraw
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-11 09:34:44 +00:00

31 lines
1.1 KiB
C#

namespace Bifrost.Web.Configuration;
/// <summary>Gates on the anonymous native registration (section <c>Bifrost:Registration</c>).</summary>
public sealed class RegistrationOptions
{
public const string SectionName = "Bifrost:Registration";
public const int MinDifficulty = 1;
public const int MaxDifficulty = 30;
public RegistrationCaptchaOptions Captcha { get; init; } = new();
public RegistrationLimitsOptions Limits { get; init; } = new();
}
/// <summary>One budget on GET /auth/bifrost/challenge and POST /auth/bifrost/register together, per source address in one fixed window.</summary>
public sealed class RegistrationLimitsOptions
{
public int PerAddressPermits { get; init; } = 10;
public TimeSpan Window { get; init; } = TimeSpan.FromMinutes(1);
public int MaxTrackedKeys { get; init; } = 10_000;
}
public sealed class RegistrationCaptchaOptions
{
/// <summary>Leading zero bits the SHA-256 of <c>challenge:nonce</c> must have. 18 is about 262k hashes, a second or two in a browser.</summary>
public int Difficulty { get; init; } = 18;
}