Skip to content

Parse the Digest Authorization header as specified by RFC 9110 - #1109

Merged
markt-asf merged 1 commit into
apache:mainfrom
arturobernalg:rfc9110-digest-credentials-parsing
Nov 17, 2026
Merged

markt-asf merged 1 commit into
apache:mainfrom
arturobernalg:rfc9110-digest-credentials-parsing

Conversation

@arturobernalg

Copy link
Copy Markdown
Member

Authorization.parseAuthorizationDigest does not follow RFC 9110 in three ways.

The authentication scheme is case-insensitive (section 11.1), but "Digest" was matched case-sensitively, so a request with digest username="a", ... was rejected and got a 401 response. The parameter names are case-insensitive (section 11.2): the parser looked up the field type with a lower case name but stored the name as received, so Username="a" was never found by DigestAuthenticator. A recipient must parse and ignore empty list elements (section 5.6.1.2), but Digest username="a",, realm="r" was rejected.

This change reads the scheme as a token and compares it ignoring case, lower cases the parameter names and skips the empty elements. As a side effect Digestusername="a", which was accepted by accident, is now rejected.

TestAuthorizationDigest has four new tests. They fail without the change and pass with it, and the other TestDigestAuthenticator* classes and TestBasicAuthParser still pass.

The authentication scheme and the parameter names are case-insensitive
(sections 11.1 and 11.2) and a recipient must ignore empty list
elements (section 5.6.1.2). The parser matched "Digest" case-sensitively,
kept the parameter names as received, so a name such as "Username" was
never found, and rejected a list with an empty element. Match the scheme
as a token, lower case the parameter names and skip the empty elements.
@arturobernalg
arturobernalg force-pushed the rfc9110-digest-credentials-parsing branch from ac5639d to 76b6fb9 Compare November 4, 2026 15:38
@arturobernalg

Copy link
Copy Markdown
Member Author

@markt-asf Addressed both comments and added regression tests. Could you take another look?

@markt-asf
markt-asf merged commit 7ed7d42 into apache:main Nov 17, 2026
11 checks passed
markt-asf added a commit that referenced this pull request Nov 17, 2026
Add a change log entry
Update RFC references
Correct digest parameter from "digest-uri" to "uri"
markt-asf pushed a commit that referenced this pull request Nov 17, 2026
The authentication scheme and the parameter names are case-insensitive
(sections 11.1 and 11.2) and a recipient must ignore empty list
elements (section 5.6.1.2). The parser matched "Digest" case-sensitively,
kept the parameter names as received, so a name such as "Username" was
never found, and rejected a list with an empty element. Match the scheme
as a token, lower case the parameter names and skip the empty elements.
markt-asf pushed a commit that referenced this pull request Nov 17, 2026
The authentication scheme and the parameter names are case-insensitive
(sections 11.1 and 11.2) and a recipient must ignore empty list
elements (section 5.6.1.2). The parser matched "Digest" case-sensitively,
kept the parameter names as received, so a name such as "Username" was
never found, and rejected a list with an empty element. Match the scheme
as a token, lower case the parameter names and skip the empty elements.
markt-asf pushed a commit that referenced this pull request Nov 17, 2026
The authentication scheme and the parameter names are case-insensitive
(sections 11.1 and 11.2) and a recipient must ignore empty list
elements (section 5.6.1.2). The parser matched "Digest" case-sensitively,
kept the parameter names as received, so a name such as "Username" was
never found, and rejected a list with an empty element. Match the scheme
as a token, lower case the parameter names and skip the empty elements.
markt-asf added a commit that referenced this pull request Nov 17, 2026
Add a change log entry
Update RFC references
Correct digest parameter from "digest-uri" to "uri"
markt-asf added a commit that referenced this pull request Nov 17, 2026
Add a change log entry
Update RFC references
Correct digest parameter from "digest-uri" to "uri"
markt-asf added a commit that referenced this pull request Nov 17, 2026
Add a change log entry
Update RFC references
Correct digest parameter from "digest-uri" to "uri"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants