From 592b949f57d4d1fcb30bcde1ec100b3cffb89c39 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Mon, 6 Jan 2025 16:32:32 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20Unterst=C3=BCtzung=20f=C3=BCr=20Token-B?= =?UTF-8?q?eschreibungen=20im=20JwtSignatureHandler=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Methoden eingeführt, um Token-Beschreibungen im DI-Container zu konfigurieren und zu registrieren. - Überladungen zu `AddJwtSignatureHandler` hinzugefügt, um sowohl konfigurationsbasierte als auch Inline-Token-Beschreibungen zu unterstützen. --- DigitalData.Core.Security/DIExtensions.cs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/DigitalData.Core.Security/DIExtensions.cs b/DigitalData.Core.Security/DIExtensions.cs index 6d1c318..09ddd79 100644 --- a/DigitalData.Core.Security/DIExtensions.cs +++ b/DigitalData.Core.Security/DIExtensions.cs @@ -61,8 +61,23 @@ namespace DigitalData.Core.Security return services.AddSingleton(sp => Options.Create(descriptor)); } - public static IServiceCollection AddJwtSignatureHandler(this IServiceCollection services, Func>? claimsMapper = null, Func? subjectMapper = null) => services - .AddClaimDescriptor(claimsMapper: claimsMapper, subjectMapper: subjectMapper) - .AddSingleton, JwtSignatureHandler>(); + public static IServiceCollection AddTokenDescriptions(this IServiceCollection services, IConfiguration configuration) + => services.Configure>(configuration); + + public static IServiceCollection AddTokenDescriptions(this IServiceCollection services, params TokenDescription[] tokenDescriptions) + => services.AddSingleton>>(Options.Create(tokenDescriptions)); + + public static IServiceCollection AddJwtSignatureHandler(this IServiceCollection services, Func>? claimsMapper = null, Func? subjectMapper = null, IConfiguration? tokenDescriptionconfig = null, params TokenDescription[]? tokenDescriptions) + { + if (tokenDescriptionconfig is not null) + services.AddTokenDescriptions(tokenDescriptionconfig); + + if (tokenDescriptions is not null) + services.AddTokenDescriptions(tokenDescriptions); + + return services + .AddClaimDescriptor(claimsMapper: claimsMapper, subjectMapper: subjectMapper) + .AddSingleton, JwtSignatureHandler>(); + } } } \ No newline at end of file