This commit is contained in:
Paul Schneider 2023-02-06 21:43:18 +00:00
commit 4f040be236
18 changed files with 144 additions and 99 deletions

View file

@ -20,12 +20,13 @@ using Microsoft.IdentityModel.Tokens;
using System;
using Microsoft.OpenApi.Models;
using System.IO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
namespace isnd
{
public class Startup
{
public static string ExternalAddress { get; internal set; }
public Startup(IConfiguration config)
{
@ -57,7 +58,7 @@ namespace isnd
.AddDefaultUI()
.AddDefaultTokenProviders();
services.AddMvc();
services.AddMvc(o=>o.EnableEndpointRouting = false);
services.AddDataProtection();
@ -90,12 +91,14 @@ namespace isnd
services.AddAuthentication("Bearer")
.AddJwtBearer("Bearer", options =>
{
options.Authority = ExternalAddress;
options.Authority = isndSettingsconf.GetValue<string>("ExternalUrl");
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateAudience = false
};
});
services.AddControllersWithViews();
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
@ -122,8 +125,9 @@ namespace isnd
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app,
Microsoft.AspNetCore.Hosting.IHostingEnvironment env,
ApplicationDbContext dbContext)
IWebHostEnvironment env,
ApplicationDbContext dbContext,
IOptions<IsndSettings> isnSettingsOption )
{
if (env.IsDevelopment())
{
@ -139,12 +143,9 @@ namespace isnd
app.UseHsts();
dbContext.Database.Migrate();
}
app.UseStatusCodePages().UseStaticFiles().UseAuthentication().UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}");
});
app.UseStatusCodePages().UseStaticFiles().UseAuthentication();
app.UseMvcWithDefaultRoute();
}
}
}