DocSpace-buildtools/web/ASC.Web.Studio/Startup.cs
pavelbannov 44ec45ebb6 Merge branch 'master' into feature/elastic
# Conflicts:
#	common/ASC.Common/Security/Cryptography/InstanceCrypto.cs
#	common/ASC.Core.Common/Billing/TariffService.cs
#	common/ASC.Core.Common/Caching/CachedQuotaService.cs
#	common/ASC.Core.Common/Caching/CachedTenantService.cs
#	common/ASC.Core.Common/Caching/CachedUserService.cs
#	common/ASC.Core.Common/Context/Impl/AuthManager.cs
#	common/ASC.Core.Common/Context/Impl/CoreConfiguration.cs
#	common/ASC.Core.Common/Context/Impl/TenantManager.cs
#	common/ASC.Core.Common/Context/SecurityContext.cs
#	common/ASC.Core.Common/Data/DbSettingsManager.cs
#	common/ASC.Core.Common/Tenants/TenantUtil.cs
#	common/ASC.Data.Reassigns/QueueWorker.cs
#	common/ASC.IPSecurity/IPSecurity.cs
#	common/services/ASC.Studio.Notify/Program.cs
#	products/ASC.People/Server/Startup.cs
#	web/ASC.Web.Core/CookiesManager.cs
#	web/ASC.Web.Core/Tfa/TfaManager.cs
2020-02-25 11:24:45 +03:00

85 lines
2.4 KiB
C#

using ASC.Api.Core.Auth;
using ASC.Common;
using ASC.Common.DependencyInjection;
using ASC.Common.Logging;
using ASC.Data.Storage;
using ASC.Data.Storage.Configuration;
using ASC.Data.Storage.DiscStorage;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace ASC.Web.Studio
{
public class Startup
{
public IConfiguration Configuration { get; }
public IHostEnvironment HostEnvironment { get; }
public Startup(IConfiguration configuration, IHostEnvironment hostEnvironment)
{
Configuration = configuration;
HostEnvironment = hostEnvironment;
}
public void ConfigureServices(IServiceCollection services)
{
services.AddHttpContextAccessor();
services.AddCors();
services.AddAuthentication("cookie").AddScheme<AuthenticationSchemeOptions, CookieAuthHandler>("cookie", a => { });
var diHelper = new DIHelper(services);
diHelper.AddNLogManager("ASC.Api", "ASC.Web");
diHelper
.AddCookieAuthHandler()
.AddStorage()
.AddPathUtilsService()
.AddStorageHandlerService();
services.AddAutofac(Configuration, HostEnvironment.ContentRootPath);
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
}
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
app.UseRouting();
app.UseCors(builder =>
builder
.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod());
app.UseAuthentication();
app.UseEndpoints(endpoints =>
{
endpoints.InitializeHttpHandlers();
});
}
}
}