The error message could be avoided with Git 2.41 (Q2 2023): it allows information carried on the WWW-AUthenticate
header to be passed to the credential helpers.
See commit 5f2117b, commit 6b8dda9, commit 988aad9 (27 Feb 2023) by Matthew John Cheetham (mjcheetham
).
(Merged by Junio C Hamano -- gitster
-- in commit 92c56da, 17 Mar 2023)
http
: read HTTP WWW-Authenticate
response headers
Signed-off-by: Matthew John Cheetham
Read and store the HTTP WWW-Authenticate response headers made for a particular request.
This will allow us to pass important authentication challenge information to credential helpers or others that would otherwise have been lost.
libcurl only provides us with the ability to read all headers recieved for a particular request, including any intermediate redirect requests or proxies.
The lines returned by libcurl
include HTTP status lines delinating any intermediate requests such as "HTTP/1.1 200
".
We use these lines to reset the strvec of WWW-Authenticate header values as we encounter them in order to only capture the final response headers.
The collection of all header values matching the WWW-Authenticate
header is complicated by the fact that it is legal for header fields to be continued over multiple lines, but libcurl only gives us each physical line a time, not each logical header.
This line folding feature is deprecated in RFC 7230 but older servers may still emit them, so we need to handle them.
In the future we may be able to leverage functions to read headers from libcurl itself, but as of today we must do this ourselves.
Credentials helpers will benefit from this:
credential
: add WWW-Authenticate header to cred requests
Signed-off-by: Matthew John Cheetham
Add the value of the WWW-Authenticate
response header to credential requests.
Credential helpers that understand and support HTTP authentication and authorization can use this standard header (RFC 2616 Section 14.47) to generate valid credentials.
WWW-Authenticate
headers can contain information pertaining to the authority, authentication mechanism, or extra parameters/scopes that are required.
The current I/O format for credential helpers only allows for unique names for properties/attributes, so in order to transmit multiple header values (with a specific order) we introduce a new convention whereby a C-style array syntax is used in the property name to denote multiple ordered values for the same property.
In this case we send multiple wwwauth[]
properties where the order that the repeated attributes appear in the conversation reflects the order that the WWW-Authenticate headers appeared in the HTTP response.
Add a set of tests to exercise the HTTP authentication header parsing and the interop with credential helpers.
Credential helpers will receive WWW-Authenticate information in credential requests.
git credential
now includes in its man page:
Attributes with keys that end with C-style array brackets []
can have
multiple values.
Each instance of a multi-valued attribute forms an
ordered list of values - the order of the repeated attributes defines
the order of the values. An empty multi-valued attribute (key[]=\n
)
acts to clear any previous entries and reset the list.
In all cases, all bytes are treated as-is (i.e., there is no quoting,
git credential
now includes in its man page:
wwwauth[]
When an HTTP response is received by Git that includes one or more
'WWW-Authenticate
' authentication headers, these will be passed by Git
to credential helpers.
Each 'WWW-Authenticate
' header value is passed as a multi-valued
attribute 'wwwauth[]
', where the order of the attributes is the same as
they appear in the HTTP response.
This attribute is 'one-way' from Git
to pass additional information to credential helpers.