|
|
|
@ -32,12 +32,20 @@ namespace isnd
|
|
|
|
|
// This method gets called by the runtime. Use this method to add services to the container.
|
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
|
{
|
|
|
|
|
services.AddDbContext<ApplicationDbContext>(options =>
|
|
|
|
|
options.UseNpgsql(
|
|
|
|
|
Configuration.GetConnectionString("DefaultConnection")));
|
|
|
|
|
|
|
|
|
|
var smtpSettingsconf = Configuration.GetSection("Smtp");
|
|
|
|
|
var isndSettingsconf = Configuration.GetSection("Isn");
|
|
|
|
|
var adminStartupListConf = Configuration.GetSection("AdminList");
|
|
|
|
|
var unleashConf = Configuration.GetSection("Unleash");
|
|
|
|
|
|
|
|
|
|
services.AddIdentity<ApplicationUser, IdentityRole>()
|
|
|
|
|
services.Configure<SmtpSettings>(smtpSettingsconf)
|
|
|
|
|
.Configure<IsndSettings>(isndSettingsconf)
|
|
|
|
|
.Configure<AdminStartupList>(adminStartupListConf)
|
|
|
|
|
.Configure<UnleashClientSettings>(unleashConf)
|
|
|
|
|
.Configure<MigrationsEndPointOptions>(o => o.Path = "~/migrate")
|
|
|
|
|
.AddDbContext<ApplicationDbContext>(options =>
|
|
|
|
|
options.UseNpgsql(
|
|
|
|
|
Configuration.GetConnectionString("DefaultConnection")))
|
|
|
|
|
.AddIdentity<ApplicationUser, IdentityRole>()
|
|
|
|
|
.AddRoles<IdentityRole>()
|
|
|
|
|
.AddEntityFrameworkStores<ApplicationDbContext>()
|
|
|
|
|
.AddSignInManager()
|
|
|
|
@ -45,12 +53,9 @@ namespace isnd
|
|
|
|
|
.AddDefaultTokenProviders();
|
|
|
|
|
|
|
|
|
|
services.AddMvc();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
services.AddDataProtection();
|
|
|
|
|
|
|
|
|
|
services.AddTransient<IMailer, EmailSender>();
|
|
|
|
|
services.AddTransient<IEmailSender, EmailSender>();
|
|
|
|
|
|
|
|
|
|
services.AddAuthorization(options =>
|
|
|
|
|
{
|
|
|
|
|
options.AddPolicy(Constants.RequireAdminPolicyName,
|
|
|
|
@ -58,26 +63,23 @@ namespace isnd
|
|
|
|
|
options.AddPolicy(Constants.RequireValidApiKey, policy =>
|
|
|
|
|
policy.Requirements.Add(new ValidApiKeyRequirement()));
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
services.AddSingleton<IAuthorizationHandler, ValidApiKeyRequirementHandler>();
|
|
|
|
|
services.AddSingleton<IUnleash>(s =>
|
|
|
|
|
})
|
|
|
|
|
.AddTransient<IMailer, EmailSender>()
|
|
|
|
|
.AddTransient<IEmailSender, EmailSender>()
|
|
|
|
|
.AddTransient<IPackageManager, PackageManager>()
|
|
|
|
|
.AddSingleton<IAuthorizationHandler, ValidApiKeyRequirementHandler>()
|
|
|
|
|
.AddSingleton(s =>
|
|
|
|
|
{
|
|
|
|
|
var config = s.GetRequiredService<IOptions<UnleashClientSettings>>();
|
|
|
|
|
if (config.Value==null)
|
|
|
|
|
throw new System.Exception("No unleash client settings");
|
|
|
|
|
if (config.Value.ApiUrl==null)
|
|
|
|
|
throw new System.Exception("No unleash client ApiUrl");
|
|
|
|
|
if (config.Value.ClientApiKey==null)
|
|
|
|
|
throw new System.Exception("No unleash client ClientApiKey");
|
|
|
|
|
return s.GetRequiredService<Microsoft.AspNetCore.Hosting.IHostingEnvironment>().CreateUnleahClient(config.Value);
|
|
|
|
|
});
|
|
|
|
|
services.AddTransient<IPackageManager, PackageManager>();
|
|
|
|
|
|
|
|
|
|
// _unleashĈlient = env.CreateUnleahClient(unleashClientSettings.Value);
|
|
|
|
|
var smtpSettingsconf = Configuration.GetSection("Smtp");
|
|
|
|
|
services.Configure<SmtpSettings>(smtpSettingsconf);
|
|
|
|
|
var isndSettingsconf = Configuration.GetSection("Isn");
|
|
|
|
|
services.Configure<IsndSettings>(isndSettingsconf);
|
|
|
|
|
var adminStartupListConf = Configuration.GetSection("AdminList");
|
|
|
|
|
services.Configure<AdminStartupList>(adminStartupListConf);
|
|
|
|
|
var unleashConf = Configuration.GetSection("Unleash");
|
|
|
|
|
services.Configure<UnleashClientSettings>(unleashConf);
|
|
|
|
|
services.Configure<MigrationsEndPointOptions>(o => o.Path = "~/migrate");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|