Skip to content

Commit 7aca051

Browse files
committed
DOCKER-462 Added environment variables to set tomcat context parameters AllowCasualMultipartParsing, AllowMultipleLeadingForwardSlashInPath and CrossContext
1 parent 2cbb23f commit 7aca051

File tree

8 files changed

+47
-26
lines changed

8 files changed

+47
-26
lines changed

2repository/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ subprojects {
120120
def composeDir = "${project.parent.projectDir}/src/integrationTest/resources";
121121

122122
useComposeFiles = ["$composeDir/docker-compose-alfresco-minimal.yml",
123-
"$composeDir/docker-compose-solr.yml", "$composeDir/docker-compose-db.yml"];
123+
"$composeDir/docker-compose-solr.yml", "$composeDir/docker-compose-db.yml", "$composeDir/docker-compose-share.yml"];
124124

125125
changedPorts {
126126
isRequiredBy(project.tasks.integrationTestChangedPorts)

README.md

Lines changed: 25 additions & 22 deletions
Large diffs are not rendered by default.

tomcat-base/src/shared/main/java/eu/xenit/alfresco/tomcat/embedded/config/DefaultConfigurationProvider.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public TomcatConfiguration getConfiguration(TomcatConfiguration baseConfiguratio
1919
baseConfiguration.setGeneratedClasspathDir("/dev/shm/classpath");
2020
baseConfiguration.setSharedClasspathDir("/usr/local/tomcat/shared/classes");
2121
baseConfiguration.setTomcatCacheMaxSize(100000);
22+
baseConfiguration.setAllowCasualMultipartParsing(false);
23+
baseConfiguration.setAllowMultipleLeadingForwardSlashInPath(true);
24+
baseConfiguration.setCrossContext(true);
2225
return baseConfiguration;
2326
}
2427
}

tomcat-base/src/shared/main/java/eu/xenit/alfresco/tomcat/embedded/config/EnvironmentVariableConfigurationProvider.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
import static eu.xenit.alfresco.tomcat.embedded.config.EnvironmentVariables.SHARED_CLASSPATH_DIR;
1010
import static eu.xenit.alfresco.tomcat.embedded.config.EnvironmentVariables.SHARED_LIB_DIR;
1111
import static eu.xenit.alfresco.tomcat.embedded.config.EnvironmentVariables.SHARE_ENABLED;
12+
import static eu.xenit.alfresco.tomcat.embedded.config.EnvironmentVariables.TOMCAT_ALLOW_CASUAL_MULTIPART_PARSING;
13+
import static eu.xenit.alfresco.tomcat.embedded.config.EnvironmentVariables.TOMCAT_ALLOW_MULTIPLE_LEADING_FORWARD_SLASH_IN_PATH;
1214
import static eu.xenit.alfresco.tomcat.embedded.config.EnvironmentVariables.TOMCAT_BASE_DIR;
1315
import static eu.xenit.alfresco.tomcat.embedded.config.EnvironmentVariables.TOMCAT_CACHE_MAX_SIZE;
16+
import static eu.xenit.alfresco.tomcat.embedded.config.EnvironmentVariables.TOMCAT_CROSS_CONTEXT;
1417
import static eu.xenit.alfresco.tomcat.embedded.config.EnvironmentVariables.TOMCAT_MAX_HTTP_HEADER_SIZE;
1518
import static eu.xenit.alfresco.tomcat.embedded.config.EnvironmentVariables.TOMCAT_MAX_THREADS;
1619
import static eu.xenit.alfresco.tomcat.embedded.config.EnvironmentVariables.TOMCAT_PORT;
@@ -44,6 +47,9 @@ public TomcatConfiguration getConfiguration(TomcatConfiguration baseConfiguratio
4447
setPropertyFromEnv(ALFRESCO_ENABLED, value -> baseConfiguration.setAlfrescoEnabled(Boolean.parseBoolean(value)));
4548
setPropertyFromEnv(SHARE_ENABLED, value -> baseConfiguration.setShareEnabled(Boolean.parseBoolean(value)));
4649
setPropertyFromEnv(TOMCAT_CACHE_MAX_SIZE, value -> baseConfiguration.setTomcatCacheMaxSize(Long.parseLong(value)));
50+
setPropertyFromEnv(TOMCAT_ALLOW_CASUAL_MULTIPART_PARSING, value -> baseConfiguration.setAllowCasualMultipartParsing(Boolean.parseBoolean(value)));
51+
setPropertyFromEnv(TOMCAT_ALLOW_MULTIPLE_LEADING_FORWARD_SLASH_IN_PATH, value -> baseConfiguration.setAllowMultipleLeadingForwardSlashInPath(Boolean.parseBoolean(value)));
52+
setPropertyFromEnv(TOMCAT_CROSS_CONTEXT, value -> baseConfiguration.setCrossContext(Boolean.parseBoolean(value)));
4753
return baseConfiguration;
4854
}
4955
}

tomcat-base/src/shared/main/java/eu/xenit/alfresco/tomcat/embedded/config/EnvironmentVariables.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public class EnvironmentVariables {
1919
public static final String GENERATED_CLASSPATH_DIR = "GENERATED_CLASSPATH_DIR";
2020
public static final String SHARED_LIB_DIR = "SHARED_LIB_DIR";
2121
public static final String TOMCAT_CACHE_MAX_SIZE = "TOMCAT_CACHE_MAX_SIZE";
22+
public static final String TOMCAT_ALLOW_CASUAL_MULTIPART_PARSING = "TOMCAT_ALLOW_CASUAL_MULTIPART_PARSING";
23+
public static final String TOMCAT_ALLOW_MULTIPLE_LEADING_FORWARD_SLASH_IN_PATH = "TOMCAT_ALLOW_MULTIPLE_LEADING_FORWARD_SLASH_IN_PATH";
24+
public static final String TOMCAT_CROSS_CONTEXT = "TOMCAT_CROSS_CONTEXT";
2225
private EnvironmentVariables() {
2326
}
2427

tomcat-base/src/shared/main/java/eu/xenit/alfresco/tomcat/embedded/config/TomcatConfiguration.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@ public class TomcatConfiguration {
2828
protected boolean shareEnabled;
2929
protected String generatedClasspathDir;
3030
protected long tomcatCacheMaxSize;
31+
protected boolean allowCasualMultipartParsing;
32+
protected boolean allowMultipleLeadingForwardSlashInPath;
33+
protected boolean crossContext;
3134
}

tomcat-base/src/shared/test/java/eu/xenit/alfresco/tomcat/embedded/config/DefaultConfigurationProviderTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ void testGetConfiguration() {
2525
expected.setGeneratedClasspathDir("/dev/shm/classpath");
2626
expected.setSharedClasspathDir("/usr/local/tomcat/shared/classes");
2727
expected.setTomcatCacheMaxSize(100000);
28+
expected.setAllowCasualMultipartParsing(false);
29+
expected.setAllowMultipleLeadingForwardSlashInPath(true);
30+
expected.setCrossContext(true);
2831
assertEquals(configuration, expected);
2932
}
3033

tomcat-base/tomcat-embedded-10/src/main/java/eu/xenit/alfresco/tomcat/embedded/tomcat/TomcatFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ private void addWebapp(Tomcat tomcat, Path path) {
132132
ctx.getAccessLog();
133133
}
134134

135-
ctx.setAllowCasualMultipartParsing(true);
136-
ctx.setAllowMultipleLeadingForwardSlashInPath(true);
137-
ctx.setCrossContext(true);
135+
ctx.setAllowCasualMultipartParsing(getConfiguration().isAllowCasualMultipartParsing());
136+
ctx.setAllowMultipleLeadingForwardSlashInPath(getConfiguration().isAllowMultipleLeadingForwardSlashInPath());
137+
ctx.setCrossContext(getConfiguration().isCrossContext());
138138
}
139139
}
140140

0 commit comments

Comments
 (0)