feat(DIExtensions): Added AddRSAPool method to configure via direct RSAParams instance.

This commit is contained in:
Developer 02 2025-03-17 09:14:23 +01:00
parent dda9b40bd3
commit a0c5144c28
2 changed files with 18 additions and 5 deletions

View File

@ -14,15 +14,28 @@ public static class DIExtensions
/// Registers a custom asym crypt service with specified parameters from the given configuration section.
/// </summary>
/// <param name="services"></param>
/// <param name="section"></param>
/// <param name="configuration"></param>
/// <returns>The updated <see cref="IServiceCollection"/> with the RSA Factory registered.</returns>
public static IServiceCollection AddCryptoFactory(this IServiceCollection services, IConfiguration configuration) => services
public static IServiceCollection AddRSAPool(this IServiceCollection services, IConfiguration configuration) => services
.Configure<RSAParams>(configuration)
.AddAutoMapper(typeof(MappingProfile).Assembly)
.AddSingleton<IAsymmetricKeyPool, RSAPool>()
.AddSingleton<IAsymmetricKeyFactory, RSAFactory>()
.AddHostedService<PemFileInitalizer>();
/// <summary>
/// Registers a custom asym crypt service with specified parameters from the given configuration section.
/// </summary>
/// <param name="services"></param>
/// <param name="rsaParams"></param>
/// <returns>The updated <see cref="IServiceCollection"/> with the RSA Factory registered.</returns>
public static IServiceCollection AddRSAPool(this IServiceCollection services, RSAParams rsaParams) => services
.AddSingleton(Options.Create(rsaParams))
.AddAutoMapper(typeof(MappingProfile).Assembly)
.AddSingleton<IAsymmetricKeyPool, RSAPool>()
.AddSingleton<IAsymmetricKeyFactory, RSAFactory>()
.AddHostedService<PemFileInitalizer>();
public static IServiceCollection AddJwtSignatureHandler<TPrincipal>(this IServiceCollection services,
Func<TPrincipal, IDictionary<string, object>>? claimsMapper = null,
Func<TPrincipal, ClaimsIdentity>? subjectMapper = null)

View File

@ -13,9 +13,9 @@ namespace DigitalData.Core.Tests.Client
[SetUp]
public void SetUp()
{
_serviceProvider = new ServiceCollection()
.AddHttpClientService("https://jsonplaceholder.typicode.com", "todos")
.BuildServiceProvider();
//_serviceProvider = new ServiceCollection()
// .AddHttpClientService("https://jsonplaceholder.typicode.com", "todos")
// .BuildServiceProvider();
_service = _serviceProvider.GetRequiredService<IBaseHttpClientService>();
}