Better debugging when working with external login providers

This commit is contained in:
Shannon
2021-08-12 15:50:47 -06:00
parent e4a2fc2736
commit c92e1beaa0

View File

@@ -58,11 +58,17 @@ namespace Umbraco.Cms.Web.Common.Security
var auth = await Context.AuthenticateAsync(ExternalAuthenticationType);
var items = auth?.Properties?.Items;
if (auth?.Principal == null || items == null || !items.ContainsKey(UmbracoSignInMgrLoginProviderKey))
if (auth?.Principal == null || items == null)
{
Logger.LogDebug("The external login authentication failed. No user Principal or authentication items was resolved.");
return null;
}
if (!items.ContainsKey(UmbracoSignInMgrLoginProviderKey))
{
throw new InvalidOperationException($"The external login authenticated successfully but the key {UmbracoSignInMgrLoginProviderKey} was not found in the authentication properties. Ensure you call SignInManager.ConfigureExternalAuthenticationProperties before issuing a ChallengeResult.");
}
if (expectedXsrf != null)
{
if (!items.ContainsKey(UmbracoSignInMgrXsrfKey))