diff --git a/Program.cs b/Program.cs index cb17783..00b50af 100644 --- a/Program.cs +++ b/Program.cs @@ -150,34 +150,6 @@ fwdOpts.KnownProxies.Clear(); app.UseForwardedHeaders(fwdOpts); app.UseRouting(); -app.Use(async (ctx, next) => -{ - var raw = ctx.Request.Headers.Cookie.ToString(); - var session = ctx.Request.Cookies[".Divers.Admin.Session"]; - if (!string.IsNullOrEmpty(raw)) - app.Logger.LogInformation("RAW Cookie Header: {Raw}", raw); - app.Logger.LogInformation("Decoded Session Cookie: {Session}", session ?? ""); - - await next(); -}); -app.Use(async (ctx, next) => -{ - // DP round-trip sanity check to verify protect/unprotect uses same key ring. - try - { - var dp = ctx.RequestServices.GetRequiredService(); - var protector = dp.CreateProtector("SystemRevivalServer.DPTest"); - var protectedValue = protector.Protect("ping"); - var unprotectedValue = protector.Unprotect(protectedValue); - app.Logger.LogInformation("DP round-trip OK: {Value}", unprotectedValue); - } - catch (Exception ex) - { - app.Logger.LogError(ex, "DP round-trip FAILED"); - } - - await next(); -}); // ---- Session middleware (must be before routing) ---- app.UseSession(); @@ -268,38 +240,6 @@ app.MapGet("/health/ready", async (IRedisManager rm, HealthCheckService hc) => catch { return Results.StatusCode(503); } }); -app.Use(async (ctx, next) => -{ - app.Logger.LogInformation("REQ {Method} {Scheme}://{Host}{Path} CookieHdrLen={Len}", - ctx.Request.Method, - ctx.Request.Scheme, - ctx.Request.Host.Value, - ctx.Request.Path.Value, - ctx.Request.Headers.Cookie.ToString().Length); - - await next(); -}); - -app.Use(async (ctx, next) => -{ - var af = ctx.Request.Cookies[".Divers.Admin.AntiForgery"]; - app.Logger.LogInformation("AF cookie present={Present} len={Len} prefix={Prefix}", - af != null, - af?.Length ?? 0, - af == null ? "" : af.Substring(0, Math.Min(25, af.Length))); - - await next(); - - if (ctx.Response.Headers.TryGetValue("Set-Cookie", out var setCookies)) - { - foreach (var sc in setCookies) - if (sc.Contains(".Divers.Admin.AntiForgery", StringComparison.OrdinalIgnoreCase)) - app.Logger.LogInformation("SET-COOKIE AF: {SetCookie}", sc); - else if (sc.Contains(".Divers.Admin.Session", StringComparison.OrdinalIgnoreCase)) - app.Logger.LogInformation("SET-COOKIE SESSION: {SetCookie}", sc); - } -}); - app.Map("/ws", async (HttpContext httpContext, NetworkManager networkManager) => diff --git a/Services/Admin/Pages/Login.cshtml.cs b/Services/Admin/Pages/Login.cshtml.cs index 3fd794a..be0c0d5 100644 --- a/Services/Admin/Pages/Login.cshtml.cs +++ b/Services/Admin/Pages/Login.cshtml.cs @@ -6,7 +6,7 @@ using GameServices.Auth; namespace GameServices.Admin.Pages; -[IgnoreAntiforgeryToken] + public class LoginModel : PageModel { private readonly GameDbContext _db; diff --git a/appsettings.json b/appsettings.json index cdd4e55..0911026 100644 --- a/appsettings.json +++ b/appsettings.json @@ -3,7 +3,6 @@ "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning", - "Microsoft.AspNetCore.DataProtection": "Debug", "Microsoft.EntityFrameworkCore.Database.Command": "Warning" } },