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