mirror of
https://github.com/Govor-team/Govor.git
synced 2026-11-16 20:56:03 +00:00
a049a80e04
Add signed, encrypted recovery archives with revision checks, account-certified device enrollment and key rotation, and historical signer lookup. Include the database migration, API endpoints, tests, and updated E2EE documentation.
42 lines
1.5 KiB
C#
42 lines
1.5 KiB
C#
using Govor.Domain.Models.Users.Crypto;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace Govor.Domain.Configurations;
|
|
|
|
public class UserCryptoSessionConfiguration : IEntityTypeConfiguration<UserCryptoSession>
|
|
{
|
|
public void Configure(EntityTypeBuilder<UserCryptoSession> builder)
|
|
{
|
|
builder.HasKey(ucs => ucs.Id);
|
|
builder.Property(c => c.Generation).IsConcurrencyToken();
|
|
builder.Property(c => c.AccountIdentityKey).HasMaxLength(200);
|
|
builder.Property(c => c.AccountSignature).HasMaxLength(100);
|
|
builder.Property(c => c.PreviousFingerprint).HasMaxLength(64);
|
|
|
|
builder.HasOne(ucs => ucs.UserSession)
|
|
.WithOne(us => us.CryptoSession)
|
|
.HasForeignKey<UserCryptoSession>(ucs => ucs.UserSessionId)
|
|
.IsRequired()
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
builder.HasOne(ucs => ucs.SignedPreKey)
|
|
.WithOne(spk => spk.UserCryptoSession)
|
|
.HasForeignKey<SignedPreKey>(spk => spk.UserCryptoSessionId)
|
|
.IsRequired()
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
builder.HasMany(ucs => ucs.OneTimePreKeys)
|
|
.WithOne(otpk => otpk.UserCryptoSession)
|
|
.HasForeignKey(otpk => otpk.UserCryptoSessionId)
|
|
.IsRequired()
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
builder.HasIndex(ucs => ucs.UserSessionId)
|
|
.IsUnique();
|
|
|
|
builder.Property(ucs => ucs.PublicIdentityKey)
|
|
.IsRequired();
|
|
}
|
|
}
|