mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
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.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using Govor.Core.Models.Users.Crypto;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Govor.Data.Configurations;
|
||||
|
||||
public class UserCryptoSessionConfiguration : IEntityTypeConfiguration<UserCryptoSession>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<UserCryptoSession> builder)
|
||||
{
|
||||
builder.HasKey(ucs => ucs.Id);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user