using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using System; namespace PoweredSoft.DynamicJwtBearer { public static class DynamicJwtBearerExtensions { public static AuthenticationBuilder AddDynamicJwtBearer(this AuthenticationBuilder builder, string authenticationScheme, Action action = null) { builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, JwtBearerPostConfigureOptions>()); if (action != null) return builder.AddScheme(authenticationScheme, null, action); return builder.AddScheme(authenticationScheme, null, _ => { }); } } }