Files
Govor/Govor.Data/Configurations/SignedPreKeyConfiguration.cs
T
Artemy 1d442d037c Add cryptographic session key management for users
Introduces a new cryptographic key management system for user sessions, including models, DTOs, interfaces, and services for handling identity keys, signed pre-keys, and one-time pre-keys. Updates the SessionKeysController and DI configuration to use the new services. Adds related EF Core configurations and migrations, and updates the UserSession model to reference the new UserCryptoSession. Removes the obsolete ISessionKeyService interface.
2025-07-30 21:26:35 +07:00

27 lines
869 B
C#

using Govor.Core.Models.Users.Crypto;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Govor.Data.Configurations;
public class SignedPreKeyConfiguration : IEntityTypeConfiguration<SignedPreKey>
{
public void Configure(EntityTypeBuilder<SignedPreKey> builder)
{
builder.HasKey(spk => spk.Id);
builder.HasOne(spk => spk.UserCryptoSession)
.WithOne(ucs => ucs.SignedPreKey)
.HasForeignKey<SignedPreKey>(spk => spk.UserCryptoSessionId)
.IsRequired()
.OnDelete(DeleteBehavior.Cascade);
builder.Property(spk => spk.PublicSignedPreKey)
.IsRequired();
builder.Property(spk => spk.SignedPreKeySignature)
.IsRequired();
builder.HasIndex(spk => spk.UserCryptoSessionId)
.IsUnique();
}
}