From 560d49d6a5400f9b4e53bf1f1e3d926620152fc0 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 22 Jul 2021 14:33:32 -0600 Subject: [PATCH] create scope to resolve named options. --- .../Security/BackOfficeAuthenticationBuilder.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web.BackOffice/Security/BackOfficeAuthenticationBuilder.cs b/src/Umbraco.Web.BackOffice/Security/BackOfficeAuthenticationBuilder.cs index 27b763218e..dd360b04f6 100644 --- a/src/Umbraco.Web.BackOffice/Security/BackOfficeAuthenticationBuilder.cs +++ b/src/Umbraco.Web.BackOffice/Security/BackOfficeAuthenticationBuilder.cs @@ -42,10 +42,17 @@ namespace Umbraco.Cms.Web.BackOffice.Security // add our login provider to the container along with a custom options configuration Services.Configure(authenticationScheme, _loginProviderOptions); - Services.AddSingleton(x => new BackOfficeExternalLoginProvider( - displayName, - authenticationScheme, - x.GetRequiredService>())); + base.Services.AddSingleton(x => + { + // need to create a scope to resolve IOptionsSnapshot + using (x.CreateScope()) + { + return new BackOfficeExternalLoginProvider( + displayName, + authenticationScheme, + x.GetRequiredService>()); + } + }); Services.TryAddEnumerable(ServiceDescriptor.Singleton, EnsureBackOfficeScheme>()); return base.AddRemoteScheme(authenticationScheme, displayName, configureOptions);