Add possibility to configure form boundaries in Jetty

The configuration options 'maxFormKeys' and 'maxFormContentSize' from
Jetty can now be set using the SCM config.yml file or environment
variables. This is required, when instances with lots of repositories
are to be migrated from 1.x to 3.x.
This commit is contained in:
Rene Pfeuffer
2025-03-12 14:43:41 +01:00
parent a4e51ebfe6
commit e1f665fc19
4 changed files with 39 additions and 19 deletions

View File

@@ -16,6 +16,8 @@
package sonia.scm.server;
import org.eclipse.jetty.server.handler.ContextHandler;
public class ServerConfigYaml {
private static final String SCM_SERVER_PREFIX = "SCM_";
@@ -30,6 +32,8 @@ public class ServerConfigYaml {
// Resolves the client ip instead of the reverse proxy ip if the X-Forwarded-For header is present
private boolean forwardHeadersEnabled = false;
private int idleTimeout = 0;
private int maxFormContentSize = ContextHandler.DEFAULT_MAX_FORM_CONTENT_SIZE;
private int maxFormKeys = ContextHandler.DEFAULT_MAX_FORM_KEYS;
// ### SSL-related config
// Only configure SSL if the key store path is set
@@ -150,6 +154,22 @@ public class ServerConfigYaml {
this.idleTimeout = idleTimeout;
}
public int getMaxFormContentSize() {
return getEnvWithDefault("MAX_FORM_CONTENT_SIZE", maxFormContentSize);
}
public void setMaxFormContentSize(int maxFormContentSize) {
this.maxFormContentSize = maxFormContentSize;
}
public int getMaxFormKeys() {
return getEnvWithDefault("MAX_FORM_KEYS", maxFormKeys);
}
public void setMaxFormKeys(int maxFormKeys) {
this.maxFormKeys = maxFormKeys;
}
static int getEnvWithDefault(String envKey, int configValue) {
String value = getEnv(envKey);
return value != null ? Integer.parseInt(value) : configValue;