2018-02-21 20:29:23 -05:00
|
|
|
|
using System;
|
2018-04-04 15:38:34 -04:00
|
|
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
2018-02-21 20:29:23 -05:00
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
|
|
namespace WebfrontCore
|
|
|
|
|
{
|
|
|
|
|
public class Startup
|
|
|
|
|
{
|
|
|
|
|
public Startup(IHostingEnvironment env)
|
|
|
|
|
{
|
|
|
|
|
var builder = new ConfigurationBuilder()
|
|
|
|
|
.SetBasePath(env.ContentRootPath)
|
2018-03-14 01:36:25 -04:00
|
|
|
|
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
|
2018-02-21 20:29:23 -05:00
|
|
|
|
.AddEnvironmentVariables();
|
2018-04-06 20:15:17 -04:00
|
|
|
|
|
2018-02-21 20:29:23 -05:00
|
|
|
|
Configuration = builder.Build();
|
2018-04-06 20:15:17 -04:00
|
|
|
|
// fixme: this is really really terrible
|
|
|
|
|
if (!SharedLibrary.Utilities.IsRunningOnMono())
|
|
|
|
|
{
|
|
|
|
|
SharedLibrary.Database.DatabaseContext.ConnectionString = Configuration["ConnectionStrings:WindowsConnection"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SharedLibrary.Database.DatabaseContext.ConnectionString = Configuration["ConnectionStrings:LinuxConnection"];
|
|
|
|
|
}
|
2018-02-21 20:29:23 -05:00
|
|
|
|
|
2018-03-18 22:25:11 -04:00
|
|
|
|
if (!IW4MAdmin.Program.Start())
|
|
|
|
|
Environment.Exit(-1);
|
2018-02-21 20:29:23 -05:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-09 03:01:12 -05:00
|
|
|
|
public static IConfigurationRoot Configuration { get; private set; }
|
2018-02-21 20:29:23 -05:00
|
|
|
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to add services to the container.
|
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
|
{
|
|
|
|
|
// Add framework services.
|
|
|
|
|
services.AddMvc();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
|
|
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
|
|
|
|
{
|
|
|
|
|
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
|
|
|
|
loggerFactory.AddDebug();
|
|
|
|
|
|
|
|
|
|
if (env.IsDevelopment())
|
|
|
|
|
{
|
|
|
|
|
app.UseDeveloperExceptionPage();
|
|
|
|
|
app.UseBrowserLink();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
app.UseExceptionHandler("/Home/Error");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.UseStaticFiles();
|
|
|
|
|
|
2018-04-04 15:38:34 -04:00
|
|
|
|
app.UseCookieAuthentication(new CookieAuthenticationOptions()
|
|
|
|
|
{
|
2018-04-07 15:49:00 -04:00
|
|
|
|
AccessDeniedPath = "/",
|
2018-04-04 15:38:34 -04:00
|
|
|
|
AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme,
|
|
|
|
|
AutomaticAuthenticate = true,
|
|
|
|
|
AutomaticChallenge = true,
|
2018-04-07 15:49:00 -04:00
|
|
|
|
LoginPath = "/",
|
2018-04-05 00:38:45 -04:00
|
|
|
|
ExpireTimeSpan = TimeSpan.FromDays(30),
|
2018-04-04 15:38:34 -04:00
|
|
|
|
});
|
|
|
|
|
|
2018-02-21 20:29:23 -05:00
|
|
|
|
app.UseMvc(routes =>
|
|
|
|
|
{
|
|
|
|
|
routes.MapRoute(
|
|
|
|
|
name: "default",
|
|
|
|
|
template: "{controller=Home}/{action=Index}/{id?}");
|
|
|
|
|
});
|
2018-04-04 15:38:34 -04:00
|
|
|
|
|
2018-02-21 20:29:23 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|