diff --git a/src/PopForums.Web/Program.cs b/src/PopForums.Web/Program.cs index 0d05a82c..3e5afec4 100644 --- a/src/PopForums.Web/Program.cs +++ b/src/PopForums.Web/Program.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Authorization; +using System; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; using PopForums.AzureKit; @@ -11,7 +12,11 @@ using Microsoft.Extensions.Logging; using Microsoft.AspNetCore.ResponseCompression; using System.IO.Compression; +using Microsoft.AspNetCore.Authentication; +using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Options; +using PopForums.Configuration; var builder = WebApplication.CreateBuilder(args); var services = builder.Services; @@ -83,6 +88,10 @@ services.Configure(options => options.Level = CompressionLevel.Fastest); +// temporary for https://github.com/dotnet/aspnetcore/discussions/56205 +services.RemoveAll(); +services.AddSingleton(); + var app = builder.Build(); if (!app.Environment.IsDevelopment()) @@ -124,4 +133,23 @@ "default", "{controller=Home}/{action=Index}/{id?}"); -app.Run(); \ No newline at end of file +app.Run(); + + +// temporary for https://github.com/dotnet/aspnetcore/discussions/56205 + +public class LoggingAuthSchemeProvider(IOptions options, IErrorLog logger) + : AuthenticationSchemeProvider(options) +{ + public override bool TryAddScheme(AuthenticationScheme scheme) + { + logger.Log(null, ErrorSeverity.Information, $"Adding scheme '{scheme.Name}'."); + return base.TryAddScheme(scheme); + } + + public override void RemoveScheme(string name) + { + logger.Log(null, ErrorSeverity.Critical, $"Removing scheme '{name}'!!!{Environment.StackTrace}"); + base.RemoveScheme(name); + } +} \ No newline at end of file