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);
        }
예제 #2
0
 public JwtDecoder(GroupAuthenticationKeys keys, ILogger <JwtDecoder> logger)
 {
     _keys   = keys;
     _logger = logger;
 }