DocSpace-buildtools/web/ASC.Web.Studio/Startup.cs

85 lines
2.4 KiB
C#
Raw Normal View History

2019-09-10 12:42:15 +00:00
using ASC.Api.Core.Auth;
2020-02-17 08:58:14 +00:00
using ASC.Common;
2019-06-06 08:44:38 +00:00
using ASC.Common.DependencyInjection;
2019-10-31 14:50:24 +00:00
using ASC.Common.Logging;
2019-06-04 14:43:20 +00:00
using ASC.Data.Storage;
2019-06-10 12:54:10 +00:00
using ASC.Data.Storage.Configuration;
2019-10-31 14:50:24 +00:00
using ASC.Data.Storage.DiscStorage;
2019-07-09 10:29:53 +00:00
using Microsoft.AspNetCore.Authentication;
2019-05-15 14:56:09 +00:00
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
2019-07-12 14:28:14 +00:00
using Microsoft.AspNetCore.HttpOverrides;
2019-05-15 14:56:09 +00:00
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)
2019-05-15 14:56:09 +00:00
{
Configuration = configuration;
HostEnvironment = hostEnvironment;
2019-05-15 14:56:09 +00:00
}
public void ConfigureServices(IServiceCollection services)
2020-02-20 14:57:48 +00:00
{
services.AddHttpContextAccessor();
2019-06-06 13:34:46 +00:00
2020-02-20 14:57:48 +00:00
services.AddCors();
2019-06-10 16:15:34 +00:00
2019-07-09 10:29:53 +00:00
services.AddAuthentication("cookie").AddScheme<AuthenticationSchemeOptions, CookieAuthHandler>("cookie", a => { });
2020-02-17 08:58:14 +00:00
var diHelper = new DIHelper(services);
2019-10-31 14:50:24 +00:00
2020-02-17 08:58:14 +00:00
diHelper.AddNLogManager("ASC.Api", "ASC.Web");
diHelper
2019-11-01 09:37:02 +00:00
.AddCookieAuthHandler()
2019-10-31 14:50:24 +00:00
.AddStorage()
.AddPathUtilsService()
2019-12-20 11:17:01 +00:00
.AddStorageHandlerService();
services.AddAutofac(Configuration, HostEnvironment.ContentRootPath);
2019-05-15 14:56:09 +00:00
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
}
2019-06-04 14:43:20 +00:00
2019-07-12 14:28:14 +00:00
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
2019-06-04 14:43:20 +00:00
app.UseRouting();
2019-05-15 14:56:09 +00:00
2019-05-30 07:33:38 +00:00
app.UseCors(builder =>
builder
.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod());
2020-02-20 14:57:48 +00:00
2019-07-09 10:29:53 +00:00
app.UseAuthentication();
2019-06-04 14:43:20 +00:00
app.UseEndpoints(endpoints =>
{
endpoints.InitializeHttpHandlers();
2019-05-15 14:56:09 +00:00
});
}
}
}