From f87fa04df5e3525e7f963205b4d2d434f7c79527 Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Fri, 21 Aug 2026 00:41:13 -0700 Subject: [PATCH] Validates antiforgery tokens after authentication --- src/Lumina.Presentation.Web/Program.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Lumina.Presentation.Web/Program.cs b/src/Lumina.Presentation.Web/Program.cs index b0fa5cac..c1e4d5bf 100644 --- a/src/Lumina.Presentation.Web/Program.cs +++ b/src/Lumina.Presentation.Web/Program.cs @@ -90,11 +90,13 @@ public class Program app.UseCultureRedirect(); // if the user attempts to go to a localized route without providing a culture, redirect to default culture app.UseApiExceptionHandling(); // handle any problem details returned by the API app.UseRouting(); - app.UseAntiforgeryFE(additionalContentTypes: ["application/json"]); // validate the antiforgery token of the JSON requests, sent via the RequestVerificationToken header app.UseRequestLocalization(); // set the culture from the localized routes app.UseSession(); app.UseAuthentication(); app.UseAuthorization(); + // validate the antiforgery token after authentication, because the token is bound to the authenticated user and + // validating it before the user is known would reject every request made by a logged-in user + app.UseAntiforgeryFE(additionalContentTypes: ["application/json"]); app.UseForwardedHeaders(); // handle path base from reverse proxies