2018-04-08 02:44:42 -04:00
|
|
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
2018-02-21 20:29:23 -05:00
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
2018-05-28 21:30:31 -04:00
|
|
|
|
using Microsoft.AspNetCore.Mvc.Razor;
|
2018-02-21 20:29:23 -05:00
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
2018-04-08 02:44:42 -04:00
|
|
|
|
using SharedLibraryCore.Database;
|
2018-02-21 20:29:23 -05:00
|
|
|
|
|
|
|
|
|
namespace WebfrontCore
|
|
|
|
|
{
|
|
|
|
|
public class Startup
|
|
|
|
|
{
|
2018-08-03 22:11:58 -04:00
|
|
|
|
private readonly IHostingEnvironment _appHost;
|
2018-04-08 02:44:42 -04:00
|
|
|
|
public static IConfigurationRoot Configuration { get; private set; }
|
|
|
|
|
|
2018-02-21 20:29:23 -05:00
|
|
|
|
public Startup(IHostingEnvironment env)
|
|
|
|
|
{
|
|
|
|
|
var builder = new ConfigurationBuilder()
|
|
|
|
|
.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
|
|
|
|
|
2018-04-08 02:44:42 -04:00
|
|
|
|
_appHost = env;
|
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.
|
2018-10-06 16:31:05 -04:00
|
|
|
|
var mvcBuilder = services.AddMvc();
|
2018-05-28 21:30:31 -04:00
|
|
|
|
|
|
|
|
|
foreach (var asm in Program.Manager.GetPluginAssemblies())
|
2018-10-06 16:31:05 -04:00
|
|
|
|
mvcBuilder.AddApplicationPart(asm);
|
2018-05-28 21:30:31 -04:00
|
|
|
|
|
|
|
|
|
services.Configure<RazorViewEngineOptions>(o =>
|
|
|
|
|
{
|
|
|
|
|
o.ViewLocationFormats.Add("/Views/Plugins/{1}/{0}" + RazorViewEngine.ViewExtension);
|
|
|
|
|
});
|
|
|
|
|
|
2018-04-08 02:44:42 -04:00
|
|
|
|
services.AddEntityFrameworkSqlite()
|
|
|
|
|
.AddDbContext<DatabaseContext>();
|
|
|
|
|
|
|
|
|
|
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
|
|
|
|
|
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options =>
|
|
|
|
|
{
|
|
|
|
|
options.AccessDeniedPath = "/";
|
|
|
|
|
options.LoginPath = "/";
|
|
|
|
|
});
|
2018-02-21 20:29:23 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
|
{
|
2018-04-19 01:48:14 -04:00
|
|
|
|
//loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
2018-02-21 20:29:23 -05:00
|
|
|
|
|
|
|
|
|
if (env.IsDevelopment())
|
|
|
|
|
{
|
2018-04-19 01:48:14 -04:00
|
|
|
|
loggerFactory.AddDebug();
|
2018-02-21 20:29:23 -05:00
|
|
|
|
app.UseDeveloperExceptionPage();
|
|
|
|
|
}
|
2019-01-26 21:33:37 -05:00
|
|
|
|
|
2018-02-21 20:29:23 -05:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
app.UseExceptionHandler("/Home/Error");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.UseStaticFiles();
|
2018-04-08 02:44:42 -04:00
|
|
|
|
app.UseAuthentication();
|
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?}");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|