mirror of
https://github.com/curl/curl.git
synced 2026-07-24 00:37:23 +03:00
http: improve AWS HTTP v4 Signature auth
- Add support services without region and service prefixes in the URL endpoint (ex. Min.IO, GCP, Yandex Cloud, Mail.Ru Cloud Solutions, etc) by providing region and service parameters via aws-sigv4 option. - Add [:region[:service]] suffix to aws-sigv4 option; - Fix memory allocation errors. - Refactor memory management. - Use Curl_http_method instead() STRING_CUSTOMREQUEST. - Refactor canonical headers generating. - Remove repeated sha256_to_hex() usage. - Add some docs fixes. - Add some codestyle fixes. - Add overloaded strndup() for debug - curl_dbg_strndup(). - Update tests. Closes #6524
This commit is contained in:
parent
3c2210713e
commit
796ce293de
21 changed files with 740 additions and 255 deletions
|
|
@ -209,7 +209,7 @@ test1800 test1801 \
|
|||
test1908 test1909 test1910 test1911 test1912 test1913 test1914 test1915 \
|
||||
test1916 test1917 test1918 \
|
||||
\
|
||||
test1933 \
|
||||
test1933 test1934 test1935 test1936 \
|
||||
\
|
||||
test2000 test2001 test2002 test2003 test2004 test2005 test2006 test2007 \
|
||||
test2008 test2009 test2010 test2011 test2012 test2013 test2014 test2015 \
|
||||
|
|
|
|||
|
|
@ -40,14 +40,14 @@ crypto
|
|||
</features>
|
||||
|
||||
<name>
|
||||
HTTP AWS_SIGV4
|
||||
HTTP AWS_SIGV4 with one provider and auth cred via URL
|
||||
</name>
|
||||
<tool>
|
||||
lib1933
|
||||
</tool>
|
||||
|
||||
<command>
|
||||
http://%HOSTIP:%HTTPPORT/1933/testapi/test
|
||||
http://xxx:yyy@%HOSTIP:%HTTPPORT/1933/testapi/test
|
||||
</command>
|
||||
</client>
|
||||
|
||||
|
|
@ -61,8 +61,8 @@ http://%HOSTIP:%HTTPPORT/1933/testapi/test
|
|||
<protocol>
|
||||
GET /1933/testapi/test HTTP/1.1
|
||||
Host: %HOSTIP:%HTTPPORT
|
||||
X-yyy-Date: 19700101T000000Z
|
||||
Authorization: XXX4-HMAC-SHA256 Credential=xxx/19700101/0/127/xxx4_request, SignedHeaders=content-type;host;x-yyy-date, Signature=b125a904e7f5cc1f553d8f3682947eb003c4ca6c504097c0dc2d9323289bfcdd
|
||||
Authorization: XXX4-HMAC-SHA256 Credential=xxx/19700101/0/127/xxx4_request, SignedHeaders=content-type;host;x-xxx-date, Signature=d2c2dff48c59ec49dc31ef94f18c5dc1ac3eae2a70d51633a4342dadc0683664
|
||||
X-Xxx-Date: 19700101T000000Z
|
||||
|
||||
</protocol>
|
||||
</verify>
|
||||
|
|
|
|||
69
tests/data/test1934
Normal file
69
tests/data/test1934
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
HTTP
|
||||
CURLOPT_AWS_SIGV4
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
# Server-side
|
||||
<reply>
|
||||
<data nocheck="yes">
|
||||
HTTP/1.1 302 OK
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
Content-Type: text/html
|
||||
Content-Length: 0
|
||||
Location: /19340002
|
||||
|
||||
</data>
|
||||
<data2>
|
||||
HTTP/1.1 200 OK
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
Content-Type: text/html
|
||||
Content-Length: 0
|
||||
|
||||
</data>
|
||||
</reply>
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
# this relies on the debug feature which allow to set the time
|
||||
<features>
|
||||
SSL
|
||||
debug
|
||||
crypto
|
||||
</features>
|
||||
|
||||
<name>
|
||||
HTTP AWS_SIGV4 with two providers
|
||||
</name>
|
||||
<tool>
|
||||
lib1934
|
||||
</tool>
|
||||
|
||||
<command>
|
||||
http://%HOSTIP:%HTTPPORT/1934/testapi/test
|
||||
</command>
|
||||
</client>
|
||||
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<strip>
|
||||
^User-Agent:.*
|
||||
^Content-Type:.*
|
||||
^Accept:.*
|
||||
</strip>
|
||||
<protocol>
|
||||
GET /1934/testapi/test HTTP/1.1
|
||||
Host: %HOSTIP:%HTTPPORT
|
||||
Authorization: XXX4-HMAC-SHA256 Credential=xxx/19700101/0/127/xxx4_request, SignedHeaders=content-type;host;x-yyy-date, Signature=938937ca7da6bb3dbf15e30928265ec6f061532d035d2afda92fa7cb10feb196
|
||||
X-Yyy-Date: 19700101T000000Z
|
||||
|
||||
</protocol>
|
||||
</verify>
|
||||
</testcase>
|
||||
69
tests/data/test1935
Normal file
69
tests/data/test1935
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
HTTP
|
||||
CURLOPT_AWS_SIGV4
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
# Server-side
|
||||
<reply>
|
||||
<data nocheck="yes">
|
||||
HTTP/1.1 302 OK
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
Content-Type: text/html
|
||||
Content-Length: 0
|
||||
Location: /19350002
|
||||
|
||||
</data>
|
||||
<data2>
|
||||
HTTP/1.1 200 OK
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
Content-Type: text/html
|
||||
Content-Length: 0
|
||||
|
||||
</data>
|
||||
</reply>
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
# this relies on the debug feature which allow to set the time
|
||||
<features>
|
||||
SSL
|
||||
debug
|
||||
crypto
|
||||
</features>
|
||||
|
||||
<name>
|
||||
HTTP AWS_SIGV4 with two providers and region
|
||||
</name>
|
||||
<tool>
|
||||
lib1935
|
||||
</tool>
|
||||
|
||||
<command>
|
||||
http://%HOSTIP:%HTTPPORT/1935/testapi/test
|
||||
</command>
|
||||
</client>
|
||||
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<strip>
|
||||
^User-Agent:.*
|
||||
^Content-Type:.*
|
||||
^Accept:.*
|
||||
</strip>
|
||||
<protocol>
|
||||
GET /1935/testapi/test HTTP/1.1
|
||||
Host: %HOSTIP:%HTTPPORT
|
||||
Authorization: XXX4-HMAC-SHA256 Credential=xxx/19700101/rrr/127/xxx4_request, SignedHeaders=content-type;host;x-yyy-date, Signature=240750deb9263d4c8ece71c016f3919b56e518249390ef075740f94ef8df846f
|
||||
X-Yyy-Date: 19700101T000000Z
|
||||
|
||||
</protocol>
|
||||
</verify>
|
||||
</testcase>
|
||||
69
tests/data/test1936
Normal file
69
tests/data/test1936
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
HTTP
|
||||
CURLOPT_AWS_SIGV4
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
# Server-side
|
||||
<reply>
|
||||
<data nocheck="yes">
|
||||
HTTP/1.1 302 OK
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
Content-Type: text/html
|
||||
Content-Length: 0
|
||||
Location: /19360002
|
||||
|
||||
</data>
|
||||
<data2>
|
||||
HTTP/1.1 200 OK
|
||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||
Server: test-server/fake
|
||||
Content-Type: text/html
|
||||
Content-Length: 0
|
||||
|
||||
</data>
|
||||
</reply>
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
# this relies on the debug feature which allow to set the time
|
||||
<features>
|
||||
SSL
|
||||
debug
|
||||
crypto
|
||||
</features>
|
||||
|
||||
<name>
|
||||
HTTP AWS_SIGV4 with two providers, region and service
|
||||
</name>
|
||||
<tool>
|
||||
lib1936
|
||||
</tool>
|
||||
|
||||
<command>
|
||||
http://%HOSTIP:%HTTPPORT/1936/testapi/test
|
||||
</command>
|
||||
</client>
|
||||
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<strip>
|
||||
^User-Agent:.*
|
||||
^Content-Type:.*
|
||||
^Accept:.*
|
||||
</strip>
|
||||
<protocol>
|
||||
GET /1936/testapi/test HTTP/1.1
|
||||
Host: %HOSTIP:%HTTPPORT
|
||||
Authorization: XXX4-HMAC-SHA256 Credential=xxx/19700101/rrr/sss/xxx4_request, SignedHeaders=content-type;host;x-yyy-date, Signature=f32cf87977cea5d3274b524b53e5d28f4aac54c372f710ae0cc3a9ececaf169f
|
||||
X-Yyy-Date: 19700101T000000Z
|
||||
|
||||
</protocol>
|
||||
</verify>
|
||||
</testcase>
|
||||
Loading…
Add table
Add a link
Reference in a new issue