net6.0
This commit is contained in:
parent
70f6e411e5
commit
4f040be236
18 changed files with 144 additions and 99 deletions
|
|
@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue