|
|
@ -1,24 +1,18 @@
|
|
|
|
using System;
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.DataProtection;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
using Microsoft.AspNetCore.Identity.UI;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.HttpsPolicy;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Identity.UI.Services;
|
|
|
|
using Microsoft.AspNetCore.Identity.UI.Services;
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
using nuget_host.Data;
|
|
|
|
using nuget_host.Data;
|
|
|
|
using nuget_host.Interfaces;
|
|
|
|
using nuget_host.Interfaces;
|
|
|
|
using nuget_host.Services;
|
|
|
|
using nuget_host.Services;
|
|
|
|
using nuget_host.Entities;
|
|
|
|
using nuget_host.Entities;
|
|
|
|
using nuget_host.Data;
|
|
|
|
using nuget_host.Authorization;
|
|
|
|
using System.Reflection;
|
|
|
|
using nuget_host.Data.Roles;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
|
|
|
|
|
|
|
namespace nuget_host
|
|
|
|
namespace nuget_host
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -40,6 +34,7 @@ namespace nuget_host
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
services.AddIdentity<ApplicationUser, IdentityRole>()
|
|
|
|
services.AddIdentity<ApplicationUser, IdentityRole>()
|
|
|
|
|
|
|
|
.AddRoles<IdentityRole>()
|
|
|
|
.AddEntityFrameworkStores<ApplicationDbContext>()
|
|
|
|
.AddEntityFrameworkStores<ApplicationDbContext>()
|
|
|
|
.AddSignInManager()
|
|
|
|
.AddSignInManager()
|
|
|
|
.AddDefaultUI()
|
|
|
|
.AddDefaultUI()
|
|
|
@ -48,14 +43,27 @@ namespace nuget_host
|
|
|
|
services.AddMvc();
|
|
|
|
services.AddMvc();
|
|
|
|
|
|
|
|
|
|
|
|
services.AddDataProtection();
|
|
|
|
services.AddDataProtection();
|
|
|
|
|
|
|
|
|
|
|
|
services.AddTransient<IMailer, EmailSender>();
|
|
|
|
services.AddTransient<IMailer, EmailSender>();
|
|
|
|
services.AddTransient<IEmailSender, EmailSender>();
|
|
|
|
services.AddTransient<IEmailSender, EmailSender>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
services.AddAuthorization(options =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
options.AddPolicy(Constants.RequireAdminPolicyName,
|
|
|
|
|
|
|
|
policy => policy.RequireRole(Constants.AdministratorRoleName));
|
|
|
|
|
|
|
|
options.AddPolicy(Constants.RequireValidApiKey, policy =>
|
|
|
|
|
|
|
|
policy.Requirements.Add(new ValidApiKeyRequirement()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
services.AddSingleton<IAuthorizationHandler, ValidApiKeyRequirementHandler>();
|
|
|
|
|
|
|
|
|
|
|
|
var smtpSettingsconf = Configuration.GetSection("Smtp");
|
|
|
|
var smtpSettingsconf = Configuration.GetSection("Smtp");
|
|
|
|
services.Configure<SmtpSettings>(smtpSettingsconf);
|
|
|
|
services.Configure<SmtpSettings>(smtpSettingsconf);
|
|
|
|
var nugetSettingsconf = Configuration.GetSection("Nuget");
|
|
|
|
var nugetSettingsconf = Configuration.GetSection("Nuget");
|
|
|
|
services.Configure<NugetSettings>(nugetSettingsconf);
|
|
|
|
services.Configure<NugetSettings>(nugetSettingsconf);
|
|
|
|
|
|
|
|
var adminStartupListConf = Configuration.GetSection("AdminList");
|
|
|
|
|
|
|
|
services.Configure<AdminStartupList>(adminStartupListConf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
|
|