Fixed missing uploads authorization check
This commit is contained in:
15
Program.cs
15
Program.cs
@@ -1,3 +1,4 @@
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -94,7 +95,19 @@ app.UseRouting();
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapStaticAssets();
|
||||
app.Use(async (context, next) =>
|
||||
{
|
||||
if (context.Request.Path.StartsWithSegments("/uploads")
|
||||
&& !(context.User.Identity?.IsAuthenticated ?? false))
|
||||
{
|
||||
context.Response.StatusCode = 401;
|
||||
return;
|
||||
}
|
||||
|
||||
await next();
|
||||
});
|
||||
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.MapControllerRoute(
|
||||
name: "default",
|
||||
|
||||
Reference in New Issue
Block a user