feat(auth): codes de récupération 2FA — 10 codes hashés à l'enrôlement, usage unique au login (Fixes #12)

This commit is contained in:
Arnaud Dartois committed 2026-08-11 21:35:52 +02:00
1 parent 9e64b03f31
commit 59a864bdfc
16 files changed
+2553 -9

No files matched your search

@@ -0,0 +1,34 @@
using Heimdall.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Heimdall.Infrastructure.Data.Configurations;
public class UserRecoveryCodeConfiguration : IEntityTypeConfiguration<UserRecoveryCode>
{
public void Configure(EntityTypeBuilder<UserRecoveryCode> builder)
{
builder.ToTable("user_recovery_codes");
builder.HasKey(r => r.Id);
builder.Property(r => r.CodeHash)
.HasMaxLength(64)
.IsRequired()
.IsUnicode(false);
builder.Property(r => r.UserId)
.IsRequired();
builder.Property(r => r.CreatedAt)
.HasDefaultValueSql("NOW()");
builder.Property(r => r.UsedAt);
// Indexes for lookup during login (single-use redemption)
builder.HasIndex(r => new { r.UserId, r.CodeHash })
.IsUnique();
builder.HasIndex(r => r.UserId);
}
}