refactor: remove ConfigureWebApiExtensionsAtFirst extension

This commit is contained in:
Developer 02 2024-08-05 15:21:42 +02:00
parent 1f9fb4163b
commit 8190e0005a
2 changed files with 21 additions and 23 deletions

View File

@ -17,6 +17,7 @@ using HRD.WebApi.DAL.Middleware;
using HRD.WebApi.Helpers;
using StaffDBServer.SharedControllers;
using HRD.LDAPService;
using Microsoft.AspNetCore.Server.IISIntegration;
AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs) =>
{
@ -41,7 +42,26 @@ try
builder.Host.UseNLog();
// Add services to the container
builder.Services.ConfigureWebApiExtensionsAtFirst(); // at first
// at first
//services.AddCors();
builder.Services.AddCustomCors("AllowAllOrigins");
builder.Services.Configure<IISOptions>(options =>
{
options.AuthenticationDisplayName = "Windows";
options.ForwardClientCertificate = true;
options.AutomaticAuthentication = true;
});
builder.Services.AddAuthentication(IISDefaults.AuthenticationScheme);
builder.Services.ConfigureJWT(StaffDBServer.Extends.JwtMiddlewareOptionsHelper.GetJwtMiddlewareOptions()); ;
builder.Services.ConfigureDAL(WebApiMiddlewareOptionsHelper.GetWebApiMiddlewareOptions());
builder.Services.AddSingleton<ILoggerManager, LoggerManager>();
builder.Services.ConfigureSwagger();
builder.Services.ConfigureRepositoryWrapper(); // add repos
var cnnStr = WebApiConfig.ConnectionString(EN_ConnectionType.SQLServer);

View File

@ -11,28 +11,6 @@ namespace StaffDBServer.SharedExtensions
{
public static class ServiceExtensions
{
public static void ConfigureWebApiExtensionsAtFirst(this IServiceCollection services)
{
//services.AddCors();
services.AddCustomCors("AllowAllOrigins");
services.Configure<IISOptions>(options =>
{
options.AuthenticationDisplayName = "Windows";
options.ForwardClientCertificate = true;
options.AutomaticAuthentication = true;
});
services.AddAuthentication(IISDefaults.AuthenticationScheme);
services.ConfigureJWT(Extends.JwtMiddlewareOptionsHelper.GetJwtMiddlewareOptions()); ;
services.ConfigureDAL(WebApiMiddlewareOptionsHelper.GetWebApiMiddlewareOptions());
services.AddSingleton<ILoggerManager, LoggerManager>();
services.ConfigureSwagger();
}
public static void ConfigureWebApiExtensionsEnd(this IServiceCollection services)
{
services.AddMvc()