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

79 lines
2.4 KiB
C#
Raw Normal View History

2020-07-06 07:56:17 +00:00
using ASC.Api.Core;
2020-02-17 08:58:14 +00:00
using ASC.Common;
2019-06-06 08:44:38 +00:00
using ASC.Common.DependencyInjection;
2020-08-27 21:52:23 +00:00
using ASC.Core.Common.EF;
using ASC.Core.Common.EF.Context;
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;
using ASC.FederatedLogin;
2020-07-15 12:33:44 +00:00
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 : BaseStartup
{
2020-07-15 12:33:44 +00:00
public override string[] LogParams { get => new string[] { "ASC.Web" }; }
public override bool AddControllers { get => false; }
2020-07-15 12:33:44 +00:00
public Startup(IConfiguration configuration, IHostEnvironment hostEnvironment) : base(configuration, hostEnvironment)
2019-05-15 14:56:09 +00:00
{
}
2020-07-15 12:33:44 +00:00
public override void ConfigureServices(IServiceCollection services)
{
2020-09-30 11:50:39 +00:00
_ = services.AddCors();
2020-07-15 12:33:44 +00:00
2020-02-17 08:58:14 +00:00
var diHelper = new DIHelper(services);
2020-09-30 11:50:39 +00:00
_ = diHelper
2019-10-31 14:50:24 +00:00
.AddStorage()
.AddPathUtilsService()
.AddStorageHandlerService()
.AddLoginHandlerService();
2020-09-30 11:50:39 +00:00
_ = services.AddMemoryCache();
2020-07-15 12:33:44 +00:00
base.ConfigureServices(services);
2020-09-30 11:50:39 +00:00
_ = services.AddAutofac(Configuration, HostEnvironment.ContentRootPath);
2019-05-15 14:56:09 +00:00
}
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
2020-07-06 07:56:17 +00:00
{
2020-08-27 21:52:23 +00:00
2020-09-30 11:50:39 +00:00
_ = app.UseForwardedHeaders(new ForwardedHeadersOptions
2019-07-12 14:28:14 +00:00
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
2020-08-27 21:52:23 +00:00
2020-09-30 11:50:39 +00:00
_ = app.UseRouting();
2019-05-15 14:56:09 +00:00
2020-09-30 11:50:39 +00:00
_ = app.UseCors(builder =>
2019-05-30 07:33:38 +00:00
builder
.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod());
2020-02-20 14:57:48 +00:00
2020-09-30 11:50:39 +00:00
_ = app.UseAuthentication();
2019-06-04 14:43:20 +00:00
2020-09-30 11:50:39 +00:00
_ = app.UseEndpoints(endpoints =>
2019-06-04 14:43:20 +00:00
{
endpoints.InitializeHttpHandlers();
});
2020-09-30 11:50:39 +00:00
_ = app.MapWhen(
context => context.Request.Path.ToString().EndsWith("login.ashx"),
appBranch =>
{
2020-09-30 11:50:39 +00:00
_ = appBranch.UseLoginHandler();
});
2019-05-15 14:56:09 +00:00
}
}
}