Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions activemq-web-console/src/main/webapp/browse.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<c:param name="JMSDestination" value="${requestContext.queueBrowser.JMSDestination}"/>
<c:param name="messageId" value="${row.JMSMessageID}"/>
<c:param name="secret" value='${sessionScope["secret"]}'/></c:url>"
onclick="return confirm('Are you sure you want to delete this message?')"
class="actionDelete"
>Delete</a>

<c:set var="queueName" value="${requestContext.queueBrowser.JMSDestination}"/>
Expand All @@ -82,7 +82,7 @@
<c:param name="JMSDestinationType" value="queue" />
<c:param name="secret" value='${sessionScope["secret"]}' />
</c:url>"
onclick="return confirm('Are you sure you want to retry this message on queue://<c:out value="${moveToQueue}"/>?')"
class="actionRetry" data-queue="<c:out value="${moveToQueue}"/>"
title="Move to <c:out value="${moveToQueue}" /> to attempt reprocessing"
>Retry</a>
</c:if>
Expand All @@ -96,6 +96,8 @@
<a href="queueConsumers.jsp?JMSDestination=<c:out value="${requestContext.queueBrowser.JMSDestination}"/>">View Consumers</a>
</div>

<script type='text/javascript' src='${pageContext.request.contextPath}/js/browse.js'></script>

<%@include file="decorators/footer.jsp" %>

</body>
Expand Down
30 changes: 30 additions & 0 deletions activemq-web-console/src/main/webapp/js/browse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

addEvent(window, 'load', (_event) => {
for (const link of document.querySelectorAll('a.actionDelete')) {
link.onclick = function(e) {
return confirm('Are you sure you want to delete this message?');
}
}

for (const link of document.querySelectorAll('a.actionRetry')) {
link.onclick = function(e) {
return confirm('Are you sure you want to retry this message on queue://' + link.dataset.queue + '?');
}
}
});
7 changes: 7 additions & 0 deletions activemq-web-console/src/main/webapp/js/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,11 @@ window.onload=function() {
document.getElementById('actionDelete').onclick = function(e) {
return confirm('Are you sure you want to delete the message?');
}

const actionRetry = document.getElementById('actionRetry');
if (actionRetry) {
actionRetry.onclick = function(e) {
return confirm('Are you sure you want to retry this message?');
}
}
}
3 changes: 1 addition & 2 deletions activemq-web-console/src/main/webapp/message.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,12 @@ No message could be found for ID <c:out value="${requestContext.messageQuery.id}
<c:if test="${requestContext.messageQuery.isDLQ() || requestContext.messageQuery.JMSDestination eq 'ActiveMQ.DLQ'}">
<tr>
<td>
<a href="<c:url value="retryMessage.action">
<a id="actionRetry" href="<c:url value="retryMessage.action">
<c:param name="JMSDestination" value="${requestContext.messageQuery.JMSDestination}" />
<c:param name="messageId" value="${row.JMSMessageID}" />
<c:param name="JMSDestinationType" value="queue" />
<c:param name="secret" value='${sessionScope["secret"]}' />
</c:url>"
onclick="return confirm('Are you sure you want to retry this message?')"
title="Retry - attempt reprocessing on original destination">Retry</a>
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.Base64;

import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
import org.eclipse.jetty.server.Server;
Expand All @@ -32,33 +34,54 @@

public class JettyServerBeanTest {

static {
if (System.getProperty("java.security.auth.login.config") == null) {
var resource = JettyServerBeanTest.class.getClassLoader().getResource("login.config");
if (resource != null) {
System.setProperty("java.security.auth.login.config", resource.getFile());
}
}
}

@Test
public void testJettyServerBean() throws Exception {
var context = new ClassPathXmlApplicationContext("conf/jetty-spring.xml");
context.start();
try {
var jettyServer = (JettyServerBean) context.getBean("jettyServer");
assertNotNull(jettyServer);

var jettyServer = (JettyServerBean) context.getBean("jettyServer");
assertNotNull(jettyServer);

Server server = jettyServer.getServer();
assertNotNull("Embedded Jetty Server should be created", server);
assertTrue("Embedded Jetty Server should be running", server.isRunning());
Server server = jettyServer.getServer();
assertNotNull("Embedded Jetty Server should be created", server);
assertTrue("Embedded Jetty Server should be running", server.isRunning());

// The console is protected by the JAAS SecurityHandler wired in
// jetty-security.xml: an unauthenticated request must be challenged
// (HTTP 401) rather than served. A request from loopback also confirms
// the InetAccessHandler allows local clients.
int port = ((ServerConnector) server.getConnectors()[0]).getLocalPort();
HttpClient client = HttpClient.newHttpClient();
HttpResponse<String> response = client.send(
HttpRequest.newBuilder(URI.create("http://127.0.0.1:" + port + "/admin/")).GET().build(),
HttpResponse.BodyHandlers.ofString());
assertEquals("Web console must require authentication", 401, response.statusCode());
// The console is protected by the JAAS SecurityHandler wired in
// jetty-security.xml: an unauthenticated request must be challenged
// (HTTP 401) rather than served. A request from loopback also confirms
// the InetAccessHandler allows local clients.
int port = ((ServerConnector) server.getConnectors()[0]).getLocalPort();
HttpClient client = HttpClient.newHttpClient();
HttpResponse<String> response = client.send(
HttpRequest.newBuilder(URI.create("http://127.0.0.1:" + port + "/admin/")).GET().build(),
HttpResponse.BodyHandlers.ofString());
assertEquals("Web console must require authentication", 401, response.statusCode());

// jetty.http.host from jetty-spring.properties: without it Jetty binds every interface
assertEquals("127.0.0.1", ((ServerConnector) server.getConnectors()[0]).getHost());
// The security headers from jetty-webapps.xml must also be sent on
// the pages served to an authenticated user.
HttpResponse<String> authenticatedResponse = client.send(
HttpRequest.newBuilder(URI.create("http://127.0.0.1:" + port + "/admin/"))
.header("Authorization", "Basic " + Base64.getEncoder().encodeToString(
"admin:admin".getBytes(StandardCharsets.ISO_8859_1)))
.GET().build(),
HttpResponse.BodyHandlers.ofString());
assertEquals(200, authenticatedResponse.statusCode());
assertEquals("SAMEORIGIN", authenticatedResponse.headers().firstValue("X-Frame-Options").orElse(null));

context.stop();
// jetty.http.host from jetty-spring.properties: without it Jetty binds every interface
assertEquals("127.0.0.1", ((ServerConnector) server.getConnectors()[0]).getHost());
} finally {
context.close();
}
}

@Test
Expand Down
18 changes: 18 additions & 0 deletions activemq-web-console/src/test/resources/groups.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## ---------------------------------------------------------------------------
## Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements. See the NOTICE file distributed with
## this work for additional information regarding copyright ownership.
## The ASF licenses this file to You under the Apache License, Version 2.0
## (the "License"); you may not use this file except in compliance with
## the License. You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------

admins=admin
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
<Configure class="org.eclipse.jetty.server.handler.ContextHandlerCollection" id="Contexts">

<!-- Rewrite Handler for Security Headers -->
<Call name="addHandler">
<Ref refid="Server">
<Call name="insertHandler">
<Arg>
<New class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
<Call name="addRule">
Expand Down Expand Up @@ -82,6 +83,7 @@
</New>
</Arg>
</Call>
</Ref>

<!-- Admin Web Application -->
<Call name="addHandler">
Expand Down
21 changes: 21 additions & 0 deletions activemq-web-console/src/test/resources/login.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
activemq {
org.apache.activemq.jaas.PropertiesLoginModule required
org.apache.activemq.jaas.properties.user="users.properties"
org.apache.activemq.jaas.properties.group="groups.properties";
};
18 changes: 18 additions & 0 deletions activemq-web-console/src/test/resources/users.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## ---------------------------------------------------------------------------
## Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements. See the NOTICE file distributed with
## this work for additional information regarding copyright ownership.
## The ASF licenses this file to You under the Apache License, Version 2.0
## (the "License"); you may not use this file except in compliance with
## the License. You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------

admin=admin
4 changes: 2 additions & 2 deletions assembly/src/release/conf/jetty-spring.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
# Jetty 12 server for the web console. Each file uses Server.insertHandler (which
# prepends), so the LAST handler loaded is the outermost. The connection limits are
# accept-time Server beans. The resulting request path (outermost -> innermost) is:
# DoS(rate limit) -> SizeLimit -> ThreadLimit -> MinDataRate -> InetAccess(IP allow)
# -> Security(JAAS auth) -> Contexts(webapps)
# Rewrite(security headers) -> DoS(rate limit) -> SizeLimit -> ThreadLimit -> MinDataRate
# -> InetAccess(IP allow) -> Security(JAAS auth) -> Contexts(webapps)
# so cheap rejections (rate/size/thread/slow-loris/IP) happen before the expensive
# JAAS authentication. jetty-webapps.xml (webAppsContext) is applied last.
# The DoS/limit handlers ship with permissive defaults; tune via jetty.dos.*,
Expand Down
4 changes: 3 additions & 1 deletion assembly/src/release/conf/jetty/jetty-webapps.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
<Configure class="org.eclipse.jetty.server.handler.ContextHandlerCollection" id="Contexts">

<!-- Rewrite Handler for Security Headers -->
<Call name="addHandler">
<Ref refid="Server">
<Call name="insertHandler">
<Arg>
<New class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
<Call name="addRule">
Expand Down Expand Up @@ -130,6 +131,7 @@
</New>
</Arg>
</Call>
</Ref>

<!-- Admin Web Application -->
<Call name="addHandler">
Expand Down