mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Merge pull request #68 from LD-Reborn/66-bugfix-swagger-and-other-endpoints-visible-outside-of-development-environment
Added endpoint authorization for swagger and elmah
This commit is contained in:
@@ -52,6 +52,20 @@ if (!app.Environment.IsDevelopment())
|
|||||||
app.UseExceptionHandler("/Home/Error");
|
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();
|
app.UseElmah();
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user