feat: LdapOptions erstellt anstelle statischer (fest codierter) Konfigurationswerte, LdapOptions und Abhängigkeitsinjektionen dafür hinzugefügt
This commit is contained in:
30
HRD.LDAPService/DIExtensions.cs
Normal file
30
HRD.LDAPService/DIExtensions.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user