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,12 @@
|
||||
namespace Govor.Core.Models.Users.Crypto;
|
||||
|
||||
public class OneTimePreKey
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid UserCryptoSessionId { get; set; }
|
||||
public UserCryptoSession UserCryptoSession { get; set; }
|
||||
|
||||
public byte[] PublicKey { get; set; }
|
||||
public bool IsUsed { get; set; }
|
||||
public DateTime UploadedAt { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Govor.Core.Models.Users.Crypto;
|
||||
|
||||
public class SignedPreKey
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid UserCryptoSessionId { get; set; }
|
||||
public UserCryptoSession UserCryptoSession { get; set; }
|
||||
public byte[] PublicSignedPreKey { get; set; }
|
||||
public byte[] SignedPreKeySignature { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace Govor.Core.Models.Users.Crypto;
|
||||
|
||||
public class UserCryptoSession
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public Guid UserSessionId { get; set; }
|
||||
public UserSession UserSession { get; set; }
|
||||
|
||||
public byte[] PublicIdentityKey { get; set; }
|
||||
|
||||
public SignedPreKey SignedPreKey { get; set; }
|
||||
public ICollection<OneTimePreKey> OneTimePreKeys { get; set; }
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
using Govor.Core.Models.Users.Crypto;
|
||||
|
||||
namespace Govor.Core.Models.Users;
|
||||
|
||||
public class UserSession
|
||||
@@ -6,11 +8,11 @@ public class UserSession
|
||||
public Guid UserId { get; set; }
|
||||
public string RefreshToken { get; set; } = string.Empty;
|
||||
public string DeviceInfo { get; set; } = string.Empty; // "Chrome on Windows"
|
||||
public string PublicEncryptionKey { get; set; }
|
||||
public string PublicSigningKey { get; set; }
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public DateTime ExpiresAt { get; set; }
|
||||
public bool IsRevoked { get; set; } = false;
|
||||
|
||||
public UserCryptoSession CryptoSession { get; set; }
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user