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

71 lines
2.1 KiB
C#
Raw Normal View History

2020-10-28 12:26:27 +00:00
2020-07-06 07:56:17 +00:00
using ASC.Api.Core;
2019-06-04 14:43:20 +00:00
using ASC.Data.Storage;
2020-10-28 12:26:27 +00:00
using ASC.Data.Storage.DiscStorage;
using ASC.FederatedLogin;
2021-02-11 09:40:30 +00:00
using ASC.FederatedLogin.LoginProviders;
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;
2019-05-15 14:56:09 +00:00
namespace ASC.Web.Studio
{
public class Startup : BaseStartup
2021-07-13 18:17:18 +00:00
{
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-10-12 19:39:23 +00:00
services.AddCors();
2020-07-15 12:33:44 +00:00
2020-10-18 16:34:30 +00:00
base.ConfigureServices(services);
2020-10-12 19:39:23 +00:00
services.AddMemoryCache();
2020-10-28 12:26:27 +00:00
DIHelper.TryAdd<Login>();
DIHelper.TryAdd<PathUtils>();
DIHelper.TryAdd<StorageHandlerScope>();
2021-02-11 09:40:30 +00:00
DIHelper.TryAdd<GoogleLoginProvider>();
DIHelper.TryAdd<FacebookLoginProvider>();
DIHelper.TryAdd<LinkedInLoginProvider>();
2019-05-15 14:56:09 +00:00
}
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
2020-07-06 07:56:17 +00:00
{
2021-06-22 16:55:47 +00:00
base.Configure(app, env);
2020-10-12 19:39:23 +00:00
app.UseForwardedHeaders(new ForwardedHeadersOptions
2019-07-12 14:28:14 +00:00
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
2020-10-12 16:23:15 +00:00
2020-10-12 19:39:23 +00:00
app.UseRouting();
2019-05-15 14:56:09 +00:00
2020-10-12 19:39:23 +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-10-12 19:39:23 +00:00
app.UseAuthentication();
2019-06-04 14:43:20 +00:00
2020-10-12 19:39:23 +00:00
app.UseEndpoints(endpoints =>
2019-06-04 14:43:20 +00:00
{
endpoints.InitializeHttpHandlers();
});
2020-10-12 19:39:23 +00:00
app.MapWhen(
context => context.Request.Path.ToString().EndsWith("login.ashx"),
appBranch =>
{
2020-10-12 19:39:23 +00:00
appBranch.UseLoginHandler();
});
2019-05-15 14:56:09 +00:00
}
}
}