This is an automated email from the ASF dual-hosted git repository.
jbertram pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/main by this push:
new b3798f2fd4 ARTEMIS-5719 Fix login to multiple web consoles with same
hostname
b3798f2fd4 is described below
commit b3798f2fd49396bd55e4c51e7276da28a9cb5f8c
Author: Domenico Francesco Bruscino <[email protected]>
AuthorDate: Fri Oct 24 16:49:31 2025 +0200
ARTEMIS-5719 Fix login to multiple web consoles with same hostname
---
.../artemis/component/WebServerComponent.java | 2 +
.../activemq/cli/test/WebServerComponentTest.java | 54 ++++++++++++++++++++++
2 files changed, 56 insertions(+)
diff --git
a/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
b/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
index 2587a0d383..6fafd1a548 100644
---
a/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
+++
b/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
@@ -194,6 +194,8 @@ public class WebServerComponent implements
ExternalComponent, WebServerComponent
WebAppContext webContext = createWebAppContext(app.url,
app.war, dirToUse, virtualHosts[i]);
handlers.addHandler(webContext);
webContext.getSessionHandler().getSessionCookieConfig().setComment("__SAME_SITE_STRICT__");
+
webContext.getSessionHandler().getSessionCookieConfig().setName("JSESSIONID_" +
i + "_" + connector.getPort());
+
webContext.getSessionHandler().setSessionPath(webContext.getContextPath());
webContext.addEventListener(new ServletContextListener() {
@Override
public void contextInitialized(ServletContextEvent sce) {
diff --git
a/artemis-web/src/test/java/org/apache/activemq/cli/test/WebServerComponentTest.java
b/artemis-web/src/test/java/org/apache/activemq/cli/test/WebServerComponentTest.java
index a80db7d2aa..deae47205f 100644
---
a/artemis-web/src/test/java/org/apache/activemq/cli/test/WebServerComponentTest.java
+++
b/artemis-web/src/test/java/org/apache/activemq/cli/test/WebServerComponentTest.java
@@ -39,8 +39,10 @@ import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Objects;
+import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -880,6 +882,48 @@ public class WebServerComponentTest extends
ArtemisTestCase {
assertFalse(webServerComponent.isStarted());
}
+ @Test
+ public void testIsolationOfSessions() throws Exception {
+ BindingDTO bindingDTO1 = new BindingDTO();
+ bindingDTO1.uri = "http://localhost:0";
+ bindingDTO1.apps = new ArrayList<>();
+ bindingDTO1.apps.add(createSimpleAppDTO("app1"));
+ bindingDTO1.apps.add(createSimpleAppDTO("app2"));
+
+ BindingDTO bindingDTO2 = new BindingDTO();
+ bindingDTO2.uri = "http://localhost:0";
+ bindingDTO2.apps = new ArrayList<>();
+ bindingDTO2.apps.add(createSimpleAppDTO("app1"));
+ bindingDTO2.apps.add(createSimpleAppDTO("app2"));
+
+ WebServerDTO webServerDTO = new WebServerDTO();
+ webServerDTO.setBindings(List.of(bindingDTO1, bindingDTO2));
+ webServerDTO.path = "";
+
+ WebServerComponent webServerComponent = new WebServerComponent();
+ assertFalse(webServerComponent.isStarted());
+ testedComponents.add(webServerComponent);
+ webServerComponent.configure(webServerDTO, "./target", "./target");
+ webServerComponent.start();
+
+ try {
+ List<Pair<WebAppContext, String>> webContextData =
webServerComponent.getWebContextData();
+ assertEquals(4, webContextData.size());
+
+ Set<String> sessionCookieNames = new HashSet<>();
+ for (Pair<WebAppContext, String> contextData : webContextData) {
+ WebAppContext webContext = contextData.getA();
+
+ String sessionCookieName =
webContext.getSessionHandler().getSessionCookieConfig().getName();
+ String sessionPath =
webContext.getSessionHandler().getSessionPath();
+ assertTrue(sessionCookieNames.add(sessionCookieName + sessionPath),
+ "A session with the name cookie " + sessionCookieName + "
and the path " + sessionPath + " already exists!");
+ }
+ } finally {
+ webServerComponent.stop(true);
+ }
+ }
+
@Test
public void testDefaultRootRedirect() throws Exception {
testRootRedirect(null, 404, null);
@@ -933,6 +977,16 @@ public class WebServerComponentTest extends
ArtemisTestCase {
return webServerDTO;
}
+ private AppDTO createSimpleAppDTO(String name) throws Exception {
+ final String warName = name + ".war";
+ createTestWar(warName);
+
+ AppDTO app = new AppDTO();
+ app.url = name + "/";
+ app.war = warName;
+ return app;
+ }
+
private void createTestWar(String warName) throws Exception {
File warFile = new File("target", warName);
File srcFile = new File("src/test/webapp");
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact