public static IServiceCollection AddGroupConfiguration(this IServiceCollection services, IConfiguration configuration, ILogger logger) { if (!string.IsNullOrEmpty(configuration["group:authenticationKey"])) { var groupKeys = new GroupAuthenticationKeys { Key = configuration["group:authenticationKey"] }; services.AddSingleton(groupKeys); services.AddSingleton <IJwtDecoder>(p => new JwtDecoder(p.GetService <GroupAuthenticationKeys>(), p.GetService <ILogger <JwtDecoder> >())); } else { logger.LogInformation("Group authenticationKey not found."); } return(services); }
public JwtDecoder(GroupAuthenticationKeys keys, ILogger <JwtDecoder> logger) { _keys = keys; _logger = logger; }