http: do not require a user name when using CURLAUTH_NEGOTIATE

In order to get Negotiate (SPNEGO) authentication to work in HTTP you
used to be required to provide a (fake) user name (this concerned both
curl and the lib) because the code wrongly only considered
authentication if there was a user name provided, as in:

  curl -u : --negotiate https://example.com/

This commit leverages the `struct auth` want member to figure out if the
user enabled CURLAUTH_NEGOTIATE, effectively removing the requirement of
setting a user name both in curl and the lib.

Signed-off-by: Marin Hannache <git@mareo.fr>
Reported-by: Enrico Scholz
Fixes https://sourceforge.net/p/curl/bugs/440/
Fixes #1161
Closes #9047
This commit is contained in:
Marin Hannache 2023-08-14 10:21:46 +02:00 committed by Daniel Stenberg
parent c90c78333b
commit 67e9e3cb1e
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
6 changed files with 10 additions and 18 deletions

View file

@ -47,7 +47,7 @@ LD_PRELOAD=%PWD/libtest/.libs/libstubgss.so
CURL_STUB_GSS_CREDS="KRB5_Alice"
</setenv>
<command>
-u: --negotiate http://%HOSTIP:%HTTPPORT/%TESTNUMBER
--negotiate http://%HOSTIP:%HTTPPORT/%TESTNUMBER
</command>
</client>

View file

@ -63,7 +63,7 @@ LD_PRELOAD=%PWD/libtest/.libs/libstubgss.so
CURL_STUB_GSS_CREDS="NTLM_Alice"
</setenv>
<command>
-u: --negotiate http://%HOSTIP:%HTTPPORT/%TESTNUMBER
--negotiate http://%HOSTIP:%HTTPPORT/%TESTNUMBER
</command>
</client>

View file

@ -29,7 +29,7 @@ GSS-API
curl --fail --negotiate to unauthenticated service fails
</name>
<command>
http://%HOSTIP:%HTTPPORT/%TESTNUMBER -u : --fail --negotiate
http://%HOSTIP:%HTTPPORT/%TESTNUMBER --fail --negotiate
</command>
</client>

View file

@ -29,7 +29,7 @@ GSS-API
curl --negotiate should not send empty POST request only
</name>
<command>
http://%HOSTIP:%HTTPPORT/%TESTNUMBER -u : --negotiate --data name=value
http://%HOSTIP:%HTTPPORT/%TESTNUMBER --negotiate --data name=value
</command>
</client>