mirror of
https://github.com/curl/curl.git
synced 2026-04-14 21:51:41 +03:00
http: only send bearer if auth is allowed
Verify with test 2006 Closes #20843
This commit is contained in:
parent
1495489c41
commit
e3d7401a32
3 changed files with 100 additions and 1 deletions
|
|
@ -705,6 +705,7 @@ static CURLcode output_auth_headers(struct Curl_easy *data,
|
|||
if(authstatus->picked == CURLAUTH_BEARER) {
|
||||
/* Bearer */
|
||||
if(!proxy && data->set.str[STRING_BEARER] &&
|
||||
Curl_auth_allowed_to_host(data) &&
|
||||
!Curl_checkheaders(data, STRCONST("Authorization"))) {
|
||||
auth = "Bearer";
|
||||
result = http_output_bearer(data);
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ test1955 test1956 test1957 test1958 test1959 test1960 test1964 \
|
|||
test1970 test1971 test1972 test1973 test1974 test1975 test1976 test1977 \
|
||||
test1978 test1979 test1980 test1981 \
|
||||
\
|
||||
test2000 test2001 test2002 test2003 test2004 test2005 \
|
||||
test2000 test2001 test2002 test2003 test2004 test2005 test2006 \
|
||||
\
|
||||
test2023 \
|
||||
test2024 test2025 test2026 test2027 test2028 test2029 test2030 test2031 \
|
||||
|
|
|
|||
98
tests/data/test2006
Normal file
98
tests/data/test2006
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
<?xml version="1.0" encoding="US-ASCII"?>
|
||||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
netrc
|
||||
HTTP
|
||||
</keywords>
|
||||
</info>
|
||||
# Server-side
|
||||
<reply>
|
||||
<data crlf="headers">
|
||||
HTTP/1.1 301 Follow this you fool
|
||||
Date: Tue, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
|
||||
ETag: "21025-dc7-39462498"
|
||||
Accept-Ranges: bytes
|
||||
Content-Length: 6
|
||||
Connection: close
|
||||
Location: http://b.com/%TESTNUMBER0002
|
||||
|
||||
-foo-
|
||||
</data>
|
||||
|
||||
<data2 crlf="headers">
|
||||
HTTP/1.1 200 OK
|
||||
Date: Tue, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
|
||||
ETag: "21025-dc7-39462498"
|
||||
Accept-Ranges: bytes
|
||||
Content-Length: 7
|
||||
Connection: close
|
||||
|
||||
target
|
||||
</data2>
|
||||
|
||||
<datacheck crlf="headers">
|
||||
HTTP/1.1 301 Follow this you fool
|
||||
Date: Tue, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
|
||||
ETag: "21025-dc7-39462498"
|
||||
Accept-Ranges: bytes
|
||||
Content-Length: 6
|
||||
Connection: close
|
||||
Location: http://b.com/%TESTNUMBER0002
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Date: Tue, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
|
||||
ETag: "21025-dc7-39462498"
|
||||
Accept-Ranges: bytes
|
||||
Content-Length: 7
|
||||
Connection: close
|
||||
|
||||
target
|
||||
</datacheck>
|
||||
</reply>
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
<features>
|
||||
proxy
|
||||
</features>
|
||||
<name>
|
||||
.netrc default with redirect plus oauth2-bearer
|
||||
</name>
|
||||
<command>
|
||||
--netrc --netrc-file %LOGDIR/netrc%TESTNUMBER --oauth2-bearer SECRET_TOKEN -L -x http://%HOSTIP:%HTTPPORT/ http://a.com/
|
||||
</command>
|
||||
<file name="%LOGDIR/netrc%TESTNUMBER" >
|
||||
default login testuser password testpass
|
||||
</file>
|
||||
</client>
|
||||
|
||||
<verify>
|
||||
<protocol crlf="headers">
|
||||
GET http://a.com/ HTTP/1.1
|
||||
Host: a.com
|
||||
Authorization: Bearer SECRET_TOKEN
|
||||
User-Agent: curl/%VERSION
|
||||
Accept: */*
|
||||
Proxy-Connection: Keep-Alive
|
||||
|
||||
GET http://b.com/%TESTNUMBER0002 HTTP/1.1
|
||||
Host: b.com
|
||||
User-Agent: curl/%VERSION
|
||||
Accept: */*
|
||||
Proxy-Connection: Keep-Alive
|
||||
|
||||
</protocol>
|
||||
</verify>
|
||||
</testcase>
|
||||
Loading…
Add table
Add a link
Reference in a new issue