Added request size limit option

This commit is contained in:
2025-04-15 15:20:58 +02:00
parent c1820bd4ed
commit 37a57cb774
2 changed files with 14 additions and 16 deletions

View File

@@ -10,6 +10,12 @@ public class AppConfiguration
public RemoteData Remote { get; set; } = new();
public FilesData Files { get; set; } = new();
public ServerData Server { get; set; } = new();
public KestrelData Kestrel { get; set; } = new();
public class KestrelData
{
public int RequestBodySizeLimit { get; set; } = 25;
}
public class RemoteData
{

View File

@@ -89,7 +89,8 @@ public class Startup
{
WebApplicationBuilder.WebHost.ConfigureKestrel(options =>
{
options.Limits.MaxRequestBodySize = ByteConverter.FromMegaBytes(Configuration.Files.UploadChunkSize).Bytes;
options.Limits.MaxRequestBodySize =
ByteConverter.FromMegaBytes(Configuration.Kestrel.RequestBodySizeLimit).Bytes;
});
return Task.CompletedTask;
@@ -375,21 +376,12 @@ public class Startup
// We are defining the access token policies here. Because the same jwt secret is used by the panel
// to generate jwt access tokens for all sorts of daemon related stuff we need to separate
// the type of access token using the type parameter provided in the claims.
options.AddPolicy("serverWebsocket", builder =>
{
builder.RequireClaim("type", "websocket");
});
options.AddPolicy("serverUpload", builder =>
{
builder.RequireClaim("type", "upload");
});
options.AddPolicy("serverDownload", builder =>
{
builder.RequireClaim("type", "download");
});
options.AddPolicy("serverWebsocket", builder => { builder.RequireClaim("type", "websocket"); });
options.AddPolicy("serverUpload", builder => { builder.RequireClaim("type", "upload"); });
options.AddPolicy("serverDownload", builder => { builder.RequireClaim("type", "download"); });
});
return Task.CompletedTask;