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 RemoteData Remote { get; set; } = new();
public FilesData Files { get; set; } = new(); public FilesData Files { get; set; } = new();
public ServerData Server { 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 public class RemoteData
{ {

View File

@@ -89,7 +89,8 @@ public class Startup
{ {
WebApplicationBuilder.WebHost.ConfigureKestrel(options => 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; return Task.CompletedTask;
@@ -376,20 +377,11 @@ public class Startup
// to generate jwt access tokens for all sorts of daemon related stuff we need to separate // 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. // the type of access token using the type parameter provided in the claims.
options.AddPolicy("serverWebsocket", builder => options.AddPolicy("serverWebsocket", builder => { builder.RequireClaim("type", "websocket"); });
{
builder.RequireClaim("type", "websocket");
});
options.AddPolicy("serverUpload", builder => options.AddPolicy("serverUpload", builder => { builder.RequireClaim("type", "upload"); });
{
builder.RequireClaim("type", "upload");
});
options.AddPolicy("serverDownload", builder => options.AddPolicy("serverDownload", builder => { builder.RequireClaim("type", "download"); });
{
builder.RequireClaim("type", "download");
});
}); });
return Task.CompletedTask; return Task.CompletedTask;