Fixed Sigv4 Signing for Managed Service (#279)
Fixed SigV4 Signing for Async Requests with QueryStrings Signed-off-by: Theo Truong <[email protected]> Signed-off-by: Theo Truong <[email protected]>
This commit is contained in:
@@ -9,7 +9,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
stack_version: ['2.1.0']
|
stack_version: ['2.1.1']
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
|||||||
+11
-3
@@ -1,15 +1,23 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||||
|
|
||||||
## [Unreleased]
|
## [2.1.1]
|
||||||
### Added
|
### Added
|
||||||
### Changed
|
### Changed
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- Fixed SigV4 Signing for Managed Service ([#279](https://github.com/opensearch-project/opensearch-py/pull/279))
|
||||||
|
- Fixed SigV4 Signing for Async Requests with QueryStrings ([#272](https://github.com/opensearch-project/opensearch-py/pull/279))
|
||||||
|
### Security
|
||||||
|
|
||||||
|
## [2.1.0]
|
||||||
|
### Added
|
||||||
|
- Added Support for AOSS ([#268](https://github.com/opensearch-project/opensearch-py/pull/268))
|
||||||
|
### Changed
|
||||||
|
### Deprecated
|
||||||
|
### Removed
|
||||||
|
### Fixed
|
||||||
### Security
|
### Security
|
||||||
|
|
||||||
## [2.0.1]
|
## [2.0.1]
|
||||||
|
|||||||
@@ -24,4 +24,4 @@
|
|||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
__versionstr__ = "2.1.0"
|
__versionstr__ = "2.1.1"
|
||||||
|
|||||||
@@ -46,11 +46,13 @@ class AWSV4SignerAsyncAuth:
|
|||||||
# create an AWS request object and sign it using SigV4Auth
|
# create an AWS request object and sign it using SigV4Auth
|
||||||
aws_request = AWSRequest(
|
aws_request = AWSRequest(
|
||||||
method=method,
|
method=method,
|
||||||
url="".join([url, query_string]),
|
url=url,
|
||||||
|
data=body,
|
||||||
)
|
)
|
||||||
|
|
||||||
sig_v4_auth = SigV4Auth(self.credentials, self.service, self.region)
|
sig_v4_auth = SigV4Auth(self.credentials, self.service, self.region)
|
||||||
sig_v4_auth.add_auth(aws_request)
|
sig_v4_auth.add_auth(aws_request)
|
||||||
|
aws_request.headers["X-Amz-Content-SHA256"] = sig_v4_auth.payload(aws_request)
|
||||||
|
|
||||||
# copy the headers from AWS request object into the prepared_request
|
# copy the headers from AWS request object into the prepared_request
|
||||||
return dict(aws_request.headers.items())
|
return dict(aws_request.headers.items())
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ class AWSV4SignerAuth(requests.auth.AuthBase):
|
|||||||
aws_request = AWSRequest(
|
aws_request = AWSRequest(
|
||||||
method=prepared_request.method.upper(),
|
method=prepared_request.method.upper(),
|
||||||
url=url,
|
url=url,
|
||||||
|
data=prepared_request.body,
|
||||||
)
|
)
|
||||||
|
|
||||||
sig_v4_auth = SigV4Auth(self.credentials, self.service, self.region)
|
sig_v4_auth = SigV4Auth(self.credentials, self.service, self.region)
|
||||||
@@ -87,5 +88,8 @@ class AWSV4SignerAuth(requests.auth.AuthBase):
|
|||||||
|
|
||||||
# copy the headers from AWS request object into the prepared_request
|
# copy the headers from AWS request object into the prepared_request
|
||||||
prepared_request.headers.update(dict(aws_request.headers.items()))
|
prepared_request.headers.update(dict(aws_request.headers.items()))
|
||||||
|
prepared_request.headers["X-Amz-Content-SHA256"] = sig_v4_auth.payload(
|
||||||
|
aws_request
|
||||||
|
)
|
||||||
|
|
||||||
return prepared_request
|
return prepared_request
|
||||||
|
|||||||
@@ -78,3 +78,4 @@ class TestAsyncSigner(TestCase):
|
|||||||
self.assertIn("Authorization", headers)
|
self.assertIn("Authorization", headers)
|
||||||
self.assertIn("X-Amz-Date", headers)
|
self.assertIn("X-Amz-Date", headers)
|
||||||
self.assertIn("X-Amz-Security-Token", headers)
|
self.assertIn("X-Amz-Security-Token", headers)
|
||||||
|
self.assertIn("X-Amz-Content-SHA256", headers)
|
||||||
|
|||||||
@@ -332,6 +332,7 @@ class TestUrllib3Connection(TestCase):
|
|||||||
self.assertIn("Authorization", prepared_request.headers)
|
self.assertIn("Authorization", prepared_request.headers)
|
||||||
self.assertIn("X-Amz-Date", prepared_request.headers)
|
self.assertIn("X-Amz-Date", prepared_request.headers)
|
||||||
self.assertIn("X-Amz-Security-Token", prepared_request.headers)
|
self.assertIn("X-Amz-Security-Token", prepared_request.headers)
|
||||||
|
self.assertIn("X-Amz-Content-SHA256", prepared_request.headers)
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
sys.version_info < (3, 6), reason="AWSV4SignerAuth requires python3.6+"
|
sys.version_info < (3, 6), reason="AWSV4SignerAuth requires python3.6+"
|
||||||
|
|||||||
Reference in New Issue
Block a user