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;
|
2020-07-28 08:13:49 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
namespace ASC.Web.Studio
|
|
|
|
{
|
2020-07-07 20:00:39 +00:00
|
|
|
public class Startup : BaseStartup
|
2019-06-26 09:26:36 +00:00
|
|
|
{
|
2020-07-15 12:33:44 +00:00
|
|
|
public override string[] LogParams { get => new string[] { "ASC.Web" }; }
|
2019-06-26 09:26:36 +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>();
|
2020-11-04 12:22:43 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-07-07 20:00:39 +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-07-28 08:13:49 +00:00
|
|
|
});
|
|
|
|
|
2020-10-12 19:39:23 +00:00
|
|
|
app.MapWhen(
|
2020-07-28 08:13:49 +00:00
|
|
|
context => context.Request.Path.ToString().EndsWith("login.ashx"),
|
|
|
|
appBranch =>
|
|
|
|
{
|
2020-10-12 19:39:23 +00:00
|
|
|
appBranch.UseLoginHandler();
|
2020-07-28 08:13:49 +00:00
|
|
|
});
|
2019-05-15 14:56:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|