diff --git a/src/Program.cs b/src/Program.cs index f3eaa4e..7d76ef1 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -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()) {