Added endpoint authorization for swagger and elmah

This commit is contained in:
2025-10-05 03:10:47 +02:00
parent 2931c55509
commit f069b70c5b

View File

@@ -52,6 +52,20 @@ if (!app.Environment.IsDevelopment())
app.UseExceptionHandler("/Home/Error");
}
app.Use(async (HttpContext context, RequestDelegate next) =>
{
if (context.Request.Path.StartsWithSegments("/elmah") || context.Request.Path.StartsWithSegments("/swagger"))
{
if (!(context.User?.Identity?.IsAuthenticated ?? false))
{
context.Response.Redirect("/Home/Login");
return;
}
}
await next(context);
});
app.UseElmah();
if (app.Environment.IsDevelopment())
{