This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new 3e19d9904c Follow-on to PR #1109. Further minor fixes for Digest auth
3e19d9904c is described below
commit 3e19d9904c9bb4bd878492b9641837a66b62cc4a
Author: Mark Thomas <[email protected]>
AuthorDate: Tue Nov 17 12:08:34 2026 +0000
Follow-on to PR #1109. Further minor fixes for Digest auth
Add a change log entry
Update RFC references
Correct digest parameter from "digest-uri" to "uri"
---
.../catalina/authenticator/DigestAuthenticator.java | 6 +++---
.../catalina/authenticator/mbeans-descriptors.xml | 2 +-
java/org/apache/catalina/authenticator/package.html | 4 ++--
.../tomcat/util/http/parser/Authorization.java | 20 +++++++++-----------
.../apache/tomcat/websocket/DigestAuthenticator.java | 2 +-
.../catalina/authenticator/TestBasicAuthParser.java | 6 +++---
.../authenticator/TestDigestAuthenticator.java | 6 +++---
.../TestNonLoginAndBasicAuthenticator.java | 2 +-
.../TestSSOnonLoginAndDigestAuthenticator.java | 17 ++++++++++++++---
.../tomcat/websocket/TestDigestAuthenticator.java | 3 +--
webapps/docs/changelog.xml | 4 ++++
webapps/docs/config/valve.xml | 2 +-
webapps/docs/realm-howto.xml | 2 +-
13 files changed, 44 insertions(+), 32 deletions(-)
diff --git a/java/org/apache/catalina/authenticator/DigestAuthenticator.java
b/java/org/apache/catalina/authenticator/DigestAuthenticator.java
index 112851de47..e9fc4e9ef0 100644
--- a/java/org/apache/catalina/authenticator/DigestAuthenticator.java
+++ b/java/org/apache/catalina/authenticator/DigestAuthenticator.java
@@ -246,7 +246,7 @@ public class DigestAuthenticator extends AuthenticatorBase {
}
/**
- * Get whether the URI should be validated as required by RFC2617.
+ * Get whether the URI should be validated as required by RFC 7616.
*
* @return {@code true} if URI validation is enabled
*/
@@ -255,7 +255,7 @@ public class DigestAuthenticator extends AuthenticatorBase {
}
/**
- * Set whether the URI should be validated as required by RFC2617.
+ * Set whether the URI should be validated as required by RFC 7616.
*
* @param validateUri {@code true} to enable URI validation
*/
@@ -715,7 +715,7 @@ public class DigestAuthenticator extends AuthenticatorBase {
if (cnonce == null || nc == null) {
return false;
}
- // RFC 2617 says nc must be 8 digits long. Older Android clients
+ // RFC 7616 says nc must be 8 digits long. Older Android clients
// use 6. 2.3.5 < fixed Android version <= 4.0.3
if (nc.length() < 6 || nc.length() > 8) {
return false;
diff --git a/java/org/apache/catalina/authenticator/mbeans-descriptors.xml
b/java/org/apache/catalina/authenticator/mbeans-descriptors.xml
index cb4b4f77bb..7d758843b7 100644
--- a/java/org/apache/catalina/authenticator/mbeans-descriptors.xml
+++ b/java/org/apache/catalina/authenticator/mbeans-descriptors.xml
@@ -135,7 +135,7 @@
writeable="false"/>
<attribute name="validateUri"
- description="Should the uri be validated as required by
RFC2617?"
+ description="Should the uri be validated as required by RFC
7616?"
type="boolean"/>
</mbean>
diff --git a/java/org/apache/catalina/authenticator/package.html
b/java/org/apache/catalina/authenticator/package.html
index 15b04ff17e..ad278c7f8f 100644
--- a/java/org/apache/catalina/authenticator/package.html
+++ b/java/org/apache/catalina/authenticator/package.html
@@ -44,9 +44,9 @@ following JavaBeans properties (with default values in square
brackets):</p>
<p>The standard authentication methods that are currently provided include:</p>
<ul>
<li><b>BasicAuthenticator</b> - Implements HTTP BASIC authentication, as
- described in RFC 2617.</li>
+ described in RFC 7617.</li>
<li><b>DigestAuthenticator</b> - Implements HTTP DIGEST authentication, as
- described in RFC 2617.</li>
+ described in RFC 7616.</li>
<li><b>FormAuthenticator</b> - Implements FORM-BASED authentication, as
described in the Servlet API Specification.</li>
</ul>
diff --git a/java/org/apache/tomcat/util/http/parser/Authorization.java
b/java/org/apache/tomcat/util/http/parser/Authorization.java
index 68e7a11c79..b51f250a8f 100644
--- a/java/org/apache/tomcat/util/http/parser/Authorization.java
+++ b/java/org/apache/tomcat/util/http/parser/Authorization.java
@@ -31,22 +31,20 @@ public class Authorization {
static {
// Digest field types.
- // Note: These are more relaxed than RFC2617. This adheres to the
- // recommendation of RFC2616 that servers are tolerant of buggy
- // clients when they can be so without ambiguity.
+ // Note: These are more relaxed than RFC 7616 without introducing
ambiguities
fieldTypes.put("username", FieldType.QUOTED_STRING);
fieldTypes.put("realm", FieldType.QUOTED_STRING);
fieldTypes.put("nonce", FieldType.QUOTED_STRING);
- fieldTypes.put("digest-uri", FieldType.QUOTED_STRING);
- // RFC2617 says response is <">32LHEX<">. 32LHEX will also be accepted
+ fieldTypes.put("uri", FieldType.QUOTED_STRING);
+ // RFC 7616 says response is quoted lower case hex. unquoted will also
be accepted
fieldTypes.put("response", FieldType.LHEX);
- // RFC2617 says algorithm is token. <">token<"> will also be accepted
+ // RFC 7616 says algorithm is token. <">token<"> will also be accepted
fieldTypes.put("algorithm", FieldType.QUOTED_TOKEN);
fieldTypes.put("cnonce", FieldType.QUOTED_STRING);
fieldTypes.put("opaque", FieldType.QUOTED_STRING);
- // RFC2617 says qop is token. <">token<"> will also be accepted
+ // RFC 7616 says qop is token. <">token<"> will also be accepted
fieldTypes.put("qop", FieldType.QUOTED_TOKEN);
- // RFC2617 says nc is 8LHEX. <">8LHEX<"> will also be accepted
+ // RFC 7616 says nc is 8LHEX. <">8LHEX<"> will also be accepted
fieldTypes.put("nc", FieldType.LHEX);
}
@@ -58,15 +56,15 @@ public class Authorization {
/**
- * Parses an HTTP Authorization header for DIGEST authentication as per
RFC 2617 section 3.2.2.
+ * Parses an HTTP Authorization header for DIGEST authentication as per
RFC 7616 section 3.4.
*
* @param input The header value to parse
*
* @return A map of directives and values as {@link String}s or
<code>null</code> if a parsing error occurs.
* Although the values returned are {@link String}s they will
have been validated to ensure that they
- * conform to RFC 2617.
+ * conform to RFC 7616.
*
- * @throws IllegalArgumentException If the header does not conform to RFC
2617
+ * @throws IllegalArgumentException If the header does not conform to RFC
7616
* @throws IOException If an error occurs while reading the
input
*/
public static Map<String,String> parseAuthorizationDigest(StringReader
input)
diff --git a/java/org/apache/tomcat/websocket/DigestAuthenticator.java
b/java/org/apache/tomcat/websocket/DigestAuthenticator.java
index aae6fcdb9f..5a420f7e68 100644
--- a/java/org/apache/tomcat/websocket/DigestAuthenticator.java
+++ b/java/org/apache/tomcat/websocket/DigestAuthenticator.java
@@ -157,7 +157,7 @@ public class DigestAuthenticator extends Authenticator {
/*
* If the "qop" value is "auth-int", then A2 is:
- * A2 = Method ":" digest-uri-value ":" H(entity-body)
+ * A2 = Method ":" request-uri ":" H(entity-body)
* There is no entity-body for a WebSocket handshake but the hash of
* the empty body still has to be included.
*/
diff --git a/test/org/apache/catalina/authenticator/TestBasicAuthParser.java
b/test/org/apache/catalina/authenticator/TestBasicAuthParser.java
index 8ed102b469..17a14c6aef 100644
--- a/test/org/apache/catalina/authenticator/TestBasicAuthParser.java
+++ b/test/org/apache/catalina/authenticator/TestBasicAuthParser.java
@@ -98,8 +98,8 @@ public class TestBasicAuthParser {
}
/*
- * RFC 2045 says the Base64 encoded string should be represented as lines
of no more than 76 characters. However,
- * RFC 2617 says a base64-user-pass token is not limited to 76 char/line.
+ * RFC 7617 uses token68 which in this case holds base 64 without
whitespace so there is no 76 character per line
+ * limit.
*/
@Test
public void testGoodCribBase64Big() throws Exception {
@@ -116,7 +116,7 @@ public class TestBasicAuthParser {
/*
- * verify the parser follows RFC2617 by treating the auth-scheme token as
case-insensitive.
+ * Verify the parser follows RFC 9110 by treating the auth-scheme token as
case-insensitive.
*/
@Test
public void testAuthMethodCaseBasic() throws Exception {
diff --git
a/test/org/apache/catalina/authenticator/TestDigestAuthenticator.java
b/test/org/apache/catalina/authenticator/TestDigestAuthenticator.java
index 0ebff3d297..349334e2c8 100644
--- a/test/org/apache/catalina/authenticator/TestDigestAuthenticator.java
+++ b/test/org/apache/catalina/authenticator/TestDigestAuthenticator.java
@@ -293,11 +293,11 @@ public class TestDigestAuthenticator extends
TomcatBaseTest {
/*
* @formatter:off
*
- * Notes from RFC2617
- * H(data) = MD5(data)
+ * Notes from RFC 7616
+ * H(data) = hash-algorithm(data)
* KD(secret, data) = H(concat(secret, ":", data))
* A1 = unq(username-value) ":" unq(realm-value) ":" passwd
- * A2 = Method ":" digest-uri-value
+ * A2 = Method ":" request-uri
* request-digest = <"> < KD ( H(A1), unq(nonce-value)
* ":" nc-value
* ":" unq(cnonce-value)
diff --git
a/test/org/apache/catalina/authenticator/TestNonLoginAndBasicAuthenticator.java
b/test/org/apache/catalina/authenticator/TestNonLoginAndBasicAuthenticator.java
index e0a3b5ba22..db405e289a 100644
---
a/test/org/apache/catalina/authenticator/TestNonLoginAndBasicAuthenticator.java
+++
b/test/org/apache/catalina/authenticator/TestNonLoginAndBasicAuthenticator.java
@@ -138,7 +138,7 @@ public class TestNonLoginAndBasicAuthenticator extends
TomcatBaseTest {
}
/*
- * This is the same as testAcceptProtectedBasic (above), except to verify
the server follows RFC2617 by treating the
+ * This is the same as testAcceptProtectedBasic (above), except to verify
the server follows RFC 9110 by treating the
* auth-scheme token as case-insensitive.
*/
@Test
diff --git
a/test/org/apache/catalina/authenticator/TestSSOnonLoginAndDigestAuthenticator.java
b/test/org/apache/catalina/authenticator/TestSSOnonLoginAndDigestAuthenticator.java
index 659dd3b4b0..46cfe6118f 100644
---
a/test/org/apache/catalina/authenticator/TestSSOnonLoginAndDigestAuthenticator.java
+++
b/test/org/apache/catalina/authenticator/TestSSOnonLoginAndDigestAuthenticator.java
@@ -339,9 +339,20 @@ public class TestSSOnonLoginAndDigestAuthenticator extends
TomcatBaseTest {
}
/*
- * Notes from RFC2617 H(data) = MD5(data) KD(secret, data) =
H(concat(secret, ":", data)) A1 = unq(username-value)
- * ":" unq(realm-value) ":" passwd A2 = Method ":" digest-uri-value
request-digest = <"> < KD ( H(A1),
- * unq(nonce-value) ":" nc-value ":" unq(cnonce-value) ":" unq(qop-value)
":" H(A2) ) <">
+ * @formatter:off
+ *
+ * Notes from RFC 7616
+ * H(data) = hash-algorithm(data)
+ * KD(secret, data) = H(concat(secret, ":", data))
+ * A1 = unq(username-value) ":" unq(realm-value) ":" passwd
+ * A2 = Method ":" request-uri
+ * request-digest = <"> < KD ( H(A1), unq(nonce-value)
+ * ":" nc-value
+ * ":" unq(cnonce-value)
+ * ":" unq(qop-value)
+ * ":" H(A2)
+ * ) <">
+ * @formatter:on
*/
private static String buildDigestResponse(String user, String pwd, String
uri, String realm, String nonce,
String opaque, String nc, String cnonce, String qop) {
diff --git a/test/org/apache/tomcat/websocket/TestDigestAuthenticator.java
b/test/org/apache/tomcat/websocket/TestDigestAuthenticator.java
index de790d458b..72f2bafdaa 100644
--- a/test/org/apache/tomcat/websocket/TestDigestAuthenticator.java
+++ b/test/org/apache/tomcat/websocket/TestDigestAuthenticator.java
@@ -73,8 +73,7 @@ public class TestDigestAuthenticator {
Assert.assertEquals("00000001", nc);
// Calculate the expected response independently of the code under
- // test, in the same way as a server would, per RFC 2617 section
- // 3.2.2.1 and RFC 7616 section 3.4.2.
+ // test, in the same way as a server would, per RFC 7616 section 3.4.2.
String a1 = userName + ":" + realm + ":" + password;
String a2 = method + ":" + requestUri;
if ("auth-int".equals(qop)) {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 383181642c..b4c0fabbb5 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -228,6 +228,10 @@
one space was required. Pull request <pr>1148</pr> provided by Arturo
Bernal. (markt)
</fix>
+ <fix>
+ Stricter parsing of the digest authentication header. Pull request
+ <pr>1109</pr> provided by Arturo Bernal. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
diff --git a/webapps/docs/config/valve.xml b/webapps/docs/config/valve.xml
index 604f84019c..2a63920b54 100644
--- a/webapps/docs/config/valve.xml
+++ b/webapps/docs/config/valve.xml
@@ -1695,7 +1695,7 @@ RequestHeader unset SSL_CLIENT_ESCAPED_CERT</source>
</attribute>
<attribute name="validateUri" required="false">
- <p>Should the URI be validated as required by RFC2617? If not
specified,
+ <p>Should the URI be validated as required by RFC 7616? If not
specified,
the default value of <code>true</code> will be used. This should
normally only be set when Tomcat is located behind a reverse proxy and
the proxy is modifying the URI passed to Tomcat such that DIGEST
diff --git a/webapps/docs/realm-howto.xml b/webapps/docs/realm-howto.xml
index d74ca6864b..20af1d9974 100644
--- a/webapps/docs/realm-howto.xml
+++ b/webapps/docs/realm-howto.xml
@@ -516,7 +516,7 @@ these passwords. In addition, the realm must handle
password digests
itself, including variations in the algorithms used and ways of
representing password hashes in the directory. However, the realm may
sometimes need access to the stored password, for example to support
-HTTP Digest Access Authentication (RFC 2069). (Note that HTTP digest
+HTTP Digest Access Authentication (RFC 7616). (Note that HTTP digest
authentication is different from the storage of password digests in
the repository for user information as discussed above).
</p>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]