From 5909f6ef8e20f6cf2b37eef54591108800df1527 Mon Sep 17 00:00:00 2001 From: Justin Baur <19896123+justindbaur@users.noreply.github.com> Date: Wed, 7 May 2025 16:51:51 -0400 Subject: [PATCH] Revert "Use IHttpMessageHandlerFactory For HTTP Communication" This reverts commit c93be6d52b12599040d3c3d8a7b3bc854c6c6802. --- .../DynamicAuthenticationSchemeProvider.cs | 1 - .../Utilities/ServiceCollectionExtensions.cs | 23 +------------------ 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/bitwarden_license/src/Sso/Utilities/DynamicAuthenticationSchemeProvider.cs b/bitwarden_license/src/Sso/Utilities/DynamicAuthenticationSchemeProvider.cs index 1dea98531e..424f91f9b7 100644 --- a/bitwarden_license/src/Sso/Utilities/DynamicAuthenticationSchemeProvider.cs +++ b/bitwarden_license/src/Sso/Utilities/DynamicAuthenticationSchemeProvider.cs @@ -35,7 +35,6 @@ public class DynamicAuthenticationSchemeProvider : AuthenticationSchemeProvider private readonly Dictionary _cachedHandlerSchemes; private readonly SemaphoreSlim _semaphore; private readonly IServiceProvider _serviceProvider; - private readonly IHttpMessageHandlerFactory _httpMessageHandlerFactory; private DateTime? _lastSchemeLoad; private IEnumerable _schemesCopy = Array.Empty(); private IEnumerable _handlerSchemesCopy = Array.Empty(); diff --git a/src/SharedWeb/Utilities/ServiceCollectionExtensions.cs b/src/SharedWeb/Utilities/ServiceCollectionExtensions.cs index 0fa37e96e5..26e5c7abaf 100644 --- a/src/SharedWeb/Utilities/ServiceCollectionExtensions.cs +++ b/src/SharedWeb/Utilities/ServiceCollectionExtensions.cs @@ -1,5 +1,4 @@ -using System.Diagnostics; -using System.Net; +using System.Net; using System.Reflection; using System.Security.Claims; using System.Security.Cryptography.X509Certificates; @@ -493,8 +492,6 @@ public static class ServiceCollectionExtensions Action addAuthorization) { services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) - // If we ever use the overload here with a different authentication scheme name then - // we need to change the AddOptions call below. .AddJwtBearer(options => { options.MapInboundClaims = false; @@ -514,24 +511,6 @@ public static class ServiceCollectionExtensions }; }); - // This is done through a Configure method instead of above so that we can avoid - // an early creation of services but still use a service that should centrally control how HttpMessageHandlers - // are created. - services.AddOptions(JwtBearerDefaults.AuthenticationScheme) - .Configure((options, httpMessageHandlerFactory) => - { - // Since we don't manually set the Backchannel and the Post stage configuration shouldn't have - // ran yet we don't expect this option to be set. If it is set, it was likely set with a - // handler already and won't respect the BackchannelHttpHandler we are about to set. - Debug.Assert(options.Backchannel is null); - - // Do a few debug checks to make sure we are customizing the expected options configured above. - Debug.Assert(!options.TokenValidationParameters.ValidateAudience); - Debug.Assert(options.TokenValidationParameters.ValidTypes.Single() == "at+jwt"); - Debug.Assert(options.TokenValidationParameters.NameClaimType == ClaimTypes.Email); - options.BackchannelHttpHandler = httpMessageHandlerFactory.CreateHandler(); - }); - if (addAuthorization != null) { services.AddAuthorization(config =>