Tweak AJP improvements · apache/tomcat@7a1406a · GitHub
Skip to content

Commit

Permalink
Tweak AJP improvements
Browse files Browse the repository at this point in the history
Better attribute name for allowedRequestAttributesPattern
Add explicit address attribute to commented out AJP connector
  • Loading branch information
markt-asf committed Feb 4, 2020
1 parent a07476e commit 7a1406a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
5 changes: 4 additions & 1 deletion conf/server.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@

<!-- Define an AJP 1.3 Connector on port 8009 -->
<!--
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Connector protocol="AJP/1.3"
address="::1"
port="8009"
redirectPort="8443" />
-->

<!-- An Engine represents the entry point (within Catalina) that processes
Expand Down
14 changes: 7 additions & 7 deletions java/org/apache/coyote/ajp/AbstractAjpProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ public boolean getSecretRequired() {
}


private Pattern allowedArbitraryRequestAttributesPattern;
public void setAllowedArbitraryRequestAttributes(String allowedArbitraryRequestAttributes) {
this.allowedArbitraryRequestAttributesPattern = Pattern.compile(allowedArbitraryRequestAttributes);
private Pattern allowedRequestAttributesPattern;
public void setAllowedRequestAttributesPattern(String allowedRequestAttributesPattern) {
this.allowedRequestAttributesPattern = Pattern.compile(allowedRequestAttributesPattern);
}
public String getAllowedArbitraryRequestAttributes() {
return allowedArbitraryRequestAttributesPattern.pattern();
public String getAllowedRequestAttributesPattern() {
return allowedRequestAttributesPattern.pattern();
}
protected Pattern getAllowedArbitraryRequestAttributesPattern() {
return allowedArbitraryRequestAttributesPattern;
protected Pattern getAllowedRequestAttributesPatternInternal() {
return allowedRequestAttributesPattern;
}


Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/coyote/ajp/AjpProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ private void prepareRequest() {
} else {
// All 'known' attributes will be processed by the previous
// blocks. Any remaining attribute is an 'arbitrary' one.
Pattern pattern = protocol.getAllowedArbitraryRequestAttributesPattern();
Pattern pattern = protocol.getAllowedRequestAttributesPatternInternal();
if (pattern == null) {
response.setStatus(403);
setErrorState(ErrorState.CLOSE_CLEAN, null);
Expand Down
2 changes: 1 addition & 1 deletion test/org/apache/coyote/ajp/TestAbstractAjpProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void setUp() throws Exception {

Connector c = getTomcatInstance().getConnector();
c.setProperty("secretRequired", "false");
c.setProperty("allowedArbitraryRequestAttributes", "MYATTRIBUTE.*");
c.setProperty("allowedRequestAttributesPattern", "MYATTRIBUTE.*");
}


Expand Down
4 changes: 2 additions & 2 deletions webapps/docs/config/ajp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
it allows greater direct manipulation of Tomcat's internal data structures
than the HTTP connectors. Particular attention should be paid to the values
used for the <code>address</code>, <code>secret</code>,
<code>secretRequired</code> and <code>allowedArbitraryRequestAttributes</code>
<code>secretRequired</code> and <code>allowedRequestAttributesPattern</code>
attributes.</p>

<p>This connector supports load balancing when used in conjunction with
Expand Down Expand Up @@ -318,7 +318,7 @@
port. By default, the loopback address will be used.</p>
</attribute>

<attribute name="allowedArbitraryRequestAttributes" required="false">
<attribute name="allowedRequestAttributesPattern" required="false">
<p>The AJP protocol passes some information from the reverse proxy to the
AJP connector using request attributes. These attributes are:</p>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion webapps/docs/security-howto.xml
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
<p>AJP Connectors block forwarded requests with unknown request
attributes. Known safe and/or expected attributes may be allowed by
configuration an appropriate regular expression for the
<code>allowedArbitraryRequestAttributes</code> attribute.</p>
<code>allowedRequestAttributesPattern</code> attribute.</p>

<p>The <strong>address</strong> attribute may be used to control which IP
address a connector listens on for connections. By default, a connector
Expand Down

0 comments on commit 7a1406a

Please sign in to comment.