From e3d9b042c24e44eeeec3f02d01467e1e2a81e934 Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Tue, 4 Mar 2025 12:12:29 +0100 Subject: [PATCH 1/2] Avoids collection was modified issue when flowing identities to the authenticated user's principal. (#18527) --- .../Extensions/HttpContextExtensions.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.Common/Extensions/HttpContextExtensions.cs b/src/Umbraco.Web.Common/Extensions/HttpContextExtensions.cs index fd46ef6903..cf90229513 100644 --- a/src/Umbraco.Web.Common/Extensions/HttpContextExtensions.cs +++ b/src/Umbraco.Web.Common/Extensions/HttpContextExtensions.cs @@ -68,7 +68,13 @@ public static class HttpContextExtensions // Otherwise we can't log in as both a member and a backoffice user // For instance if you've enabled basic auth. ClaimsPrincipal? authenticatedPrincipal = result.Principal; - IEnumerable existingIdentities = httpContext.User.Identities.Where(x => x.IsAuthenticated && x.AuthenticationType != authenticatedPrincipal.Identity.AuthenticationType); + + // Make sure to copy into a list before attempting to update the authenticated principal, so we don't attempt to modify + // the collection while iterating it. + // See: https://github.com/umbraco/Umbraco-CMS/issues/18509 + var existingIdentities = httpContext.User.Identities + .Where(x => x.IsAuthenticated && x.AuthenticationType != authenticatedPrincipal.Identity.AuthenticationType) + .ToList(); authenticatedPrincipal.AddIdentities(existingIdentities); httpContext.User = authenticatedPrincipal; From fd5b8de53349b067cfddf700d006aefd1471c7b4 Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Wed, 12 Mar 2025 07:25:35 +0100 Subject: [PATCH 2/2] Bumped version to 13.7.2 --- version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.json b/version.json index a6ac6f44b4..043d77464c 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json", - "version": "13.7.1", + "version": "13.7.2", "assemblyVersion": { "precision": "build" },