From 1bc5466a8ded0ec87e06a9d9da35f49d62fe080b Mon Sep 17 00:00:00 2001 From: Elitsa Date: Tue, 20 Aug 2024 10:15:37 +0200 Subject: [PATCH] Update the HttpContext's user with the authenticated user's principal --- .../Extensions/HttpContextExtensions.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Umbraco.Web.Common/Extensions/HttpContextExtensions.cs b/src/Umbraco.Web.Common/Extensions/HttpContextExtensions.cs index 0f2da0ac4e..0a84f318f6 100644 --- a/src/Umbraco.Web.Common/Extensions/HttpContextExtensions.cs +++ b/src/Umbraco.Web.Common/Extensions/HttpContextExtensions.cs @@ -59,6 +59,14 @@ public static class HttpContextExtensions await httpContext.AuthenticateAsync(Constants.Security.BackOfficeExternalAuthenticationType); } + // Update the HttpContext's user with the authenticated user's principal to ensure + // that subsequent requests within the same context will recognize the user + // as authenticated. + if (result.Succeeded) + { + httpContext.User = result.Principal; + } + return result; }