From 26c78d32aefaf4b63c850f5109ca5d77ed892a83 Mon Sep 17 00:00:00 2001 From: TekH Date: Tue, 18 Aug 2026 15:49:44 +0200 Subject: [PATCH] Remove encryption service and related configurations The `IEncryptionService` interface and its implementation, `DataProtectionEncryptionService`, have been removed from the codebase. These components previously provided encryption and decryption functionality using the ASP.NET Core Data Protection API. Additionally, the dependency injection setup for the encryption service and the Data Protection API configuration (e.g., key persistence and application name) have been removed from `DependencyInjection.cs`. --- .../Common/Interfaces/IEncryptionService.cs | 10 -------- .../DependencyInjection.cs | 8 ------- .../DataProtectionEncryptionService.cs | 23 ------------------- 3 files changed, 41 deletions(-) delete mode 100644 src/core/DigitalData.MessagingService.Application/Common/Interfaces/IEncryptionService.cs delete mode 100644 src/infrastructure/DigitalData.MessagingService.Infrastructure/Services/DataProtectionEncryptionService.cs diff --git a/src/core/DigitalData.MessagingService.Application/Common/Interfaces/IEncryptionService.cs b/src/core/DigitalData.MessagingService.Application/Common/Interfaces/IEncryptionService.cs deleted file mode 100644 index a92fa0f..0000000 --- a/src/core/DigitalData.MessagingService.Application/Common/Interfaces/IEncryptionService.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace DigitalData.MessagingService.Application.Common.Interfaces; - -/// -/// Encryption service interface for password encryption. -/// -public interface IEncryptionService -{ - string Encrypt(string plainText); - string Decrypt(string cipherText); -} diff --git a/src/infrastructure/DigitalData.MessagingService.Infrastructure/DependencyInjection.cs b/src/infrastructure/DigitalData.MessagingService.Infrastructure/DependencyInjection.cs index 0b6faf3..9fe3f9b 100644 --- a/src/infrastructure/DigitalData.MessagingService.Infrastructure/DependencyInjection.cs +++ b/src/infrastructure/DigitalData.MessagingService.Infrastructure/DependencyInjection.cs @@ -53,9 +53,6 @@ public static class DependencyInjection // PDF Processing Service (using DevExpress.Pdf) services.AddScoped(); - // Encryption Service (using Data Protection API - Singleton, thread-safe) - services.AddSingleton(); - // --- Email Queue (RabbitMQ) --- services.AddSingleton(); services.AddMessagingServicePublisher(); @@ -63,11 +60,6 @@ public static class DependencyInjection // --- RabbitMQ Configuration --- services.AddRabbitMqConnectionFactory(configuration); - // --- Data Protection (for encryption) --- - services.AddDataProtection() - .PersistKeysToFileSystem(new DirectoryInfo(@"C:\ProgramData\EmailService\Keys")) - .SetApplicationName("MessagingService"); - // Register Background Workers services.AddHostedService(); services.AddHostedService(); diff --git a/src/infrastructure/DigitalData.MessagingService.Infrastructure/Services/DataProtectionEncryptionService.cs b/src/infrastructure/DigitalData.MessagingService.Infrastructure/Services/DataProtectionEncryptionService.cs deleted file mode 100644 index d0ca9fe..0000000 --- a/src/infrastructure/DigitalData.MessagingService.Infrastructure/Services/DataProtectionEncryptionService.cs +++ /dev/null @@ -1,23 +0,0 @@ -using DigitalData.MessagingService.Application.Common.Interfaces; -using Microsoft.AspNetCore.DataProtection; - -namespace DigitalData.MessagingService.Infrastructure.Services; - -/// -/// Encryption service using ASP.NET Core Data Protection API. -/// Passwords are encrypted at rest in the database. -/// -public class DataProtectionEncryptionService(IDataProtectionProvider Provider) : IEncryptionService -{ - private readonly IDataProtector Protector = Provider.CreateProtector("MessagingService.Passwords"); - - public string Encrypt(string plainText) - { - return Protector.Protect(plainText); - } - - public string Decrypt(string cipherText) - { - return Protector.Unprotect(cipherText); - } -}