Registration: server-rendered sign-up form with script solver and time-lock fallback

GET /auth/bifrost/register renders the form (notice in full, unchecked consent box);
POST /auth/bifrost/register/form and the JSON endpoint share NativeRegistration.
Challenge payload gains issued-at; waited path needs FallbackWaitSeconds and a
stricter per-address FallbackPermits budget.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Heimdall 2026-11-11 10:26:24 +00:00
commit 9c4ab5646a
9 changed files with 1136 additions and 58 deletions

View file

@ -1,5 +1,6 @@
using Bifrost.Web.Configuration;
using Bifrost.Web.Features.ConceptVotes;
using Bifrost.Web.Features.Registration;
using Microsoft.Extensions.Options;
namespace Bifrost.Web.Features.Shared;
@ -55,12 +56,24 @@ public sealed class StartupConfigurationValidator(
failures.Add($"Bifrost:Registration:Captcha:Difficulty must be between {RegistrationOptions.MinDifficulty} and {RegistrationOptions.MaxDifficulty}.");
}
var wait = registrationOptions.Value.Captcha.FallbackWaitSeconds;
if (wait < RegistrationOptions.MinFallbackWaitSeconds || wait > RegistrationOptions.MaxFallbackWaitSeconds ||
wait >= RegistrationChallengeService.Lifetime.TotalSeconds)
{
failures.Add($"Bifrost:Registration:Captcha:FallbackWaitSeconds must be between {RegistrationOptions.MinFallbackWaitSeconds} and {RegistrationOptions.MaxFallbackWaitSeconds} and shorter than the challenge lifetime ({RegistrationChallengeService.Lifetime.TotalSeconds:0} seconds).");
}
var limits = registrationOptions.Value.Limits;
if (limits.PerAddressPermits < 1 || limits.Window <= TimeSpan.Zero || limits.MaxTrackedKeys < 1)
{
failures.Add("Bifrost:Registration:Limits:PerAddressPermits and MaxTrackedKeys must be at least 1 and Window must be positive.");
}
if (limits.FallbackPermits < 1 || limits.FallbackWindow <= TimeSpan.Zero)
{
failures.Add("Bifrost:Registration:Limits:FallbackPermits must be at least 1 and FallbackWindow must be positive.");
}
if (hostEnvironment.IsDevelopment() || hostEnvironment.IsEnvironment("Testing"))
{
Refuse(failures);