+ Revsion

This commit is contained in:
Paul Schneider 2022-09-26 21:54:22 +01:00
commit 9c4d45b97c
6 changed files with 397 additions and 34 deletions

View file

@ -1,8 +1,11 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.Extensions.Hosting;
using isnd.Data;
using isnd.Interfaces;
using isnd.Services;
@ -14,8 +17,6 @@ using Unleash;
using Microsoft.Extensions.Options;
using isnd.Helpers;
using Microsoft.IdentityModel.Tokens;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace isnd
{
@ -50,13 +51,7 @@ namespace isnd
.AddSignInManager()
.AddDefaultUI()
.AddDefaultTokenProviders();
/*
services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders =
ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
});
*/
services.AddMvc();
services.AddDataProtection();
@ -83,17 +78,20 @@ namespace isnd
throw new System.Exception("No unleash client ApiUrl");
if (config.Value.ClientApiKey==null)
throw new System.Exception("No unleash client ClientApiKey");
return s.GetRequiredService<IHostingEnvironment>().CreateUnleahClient(config.Value);
return s.GetRequiredService<Microsoft.AspNetCore.Hosting.IHostingEnvironment>().CreateUnleahClient(config.Value);
});
services.AddAuthentication("Bearer")
.AddJwtBearer("Bearer", options =>
{
options.Authority = "https://localhost:5001";
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateAudience = false
};
});
}
@ -103,30 +101,23 @@ namespace isnd
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app,
IHostingEnvironment env,
Microsoft.AspNetCore.Hosting.IHostingEnvironment env,
ApplicationDbContext dbContext)
{
// app.UseForwardedHeaders();
// app.UseDeveloperExceptionPage();
// app.UseHttpsRedirection();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseMigrationsEndPoint();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
dbContext.Database.Migrate();
}
_ = app
.UseStaticFiles()
.UseAuthentication()
.UseMvc(routes =>
// app.UseHttpsRedirection();
app.UseStatusCodePages().UseStaticFiles().UseAuthentication().UseMvc(routes =>
{
routes.MapRoute(
name: "default",