feat: LdapOptions erstellt anstelle statischer (fest codierter) Konfigurationswerte, LdapOptions und Abhängigkeitsinjektionen dafür hinzugefügt

This commit is contained in:
Developer 02
2024-08-05 14:18:20 +02:00
parent bc04c2d36d
commit d434a5964b
8 changed files with 105 additions and 21 deletions

View File

@@ -0,0 +1,30 @@
using HRD.LDAPService.JWT;
using HRD.LDAPService.Ldap;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
namespace HRD.LDAPService
{
public static class DIExtensions
{
private static IServiceCollection AddJwtManagerWithLdap(this IServiceCollection services)
{
services
.AddSingleton<LdapAuthenticationService>()
.AddSingleton<JwtManager>();
return services;
}
public static IServiceCollection AddJwtManagerWithLdap(this IServiceCollection services, Action<LdapOptions> configureOptions)
=> services
.Configure(configureOptions)
.AddJwtManagerWithLdap();
public static IServiceCollection AddJwtManagerWithLdap(this IServiceCollection services, IConfiguration configuration)
=> services
.Configure<LdapOptions>(configuration)
.AddJwtManagerWithLdap();
}
}