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:
Theo Nam Truong
2023-01-23 18:38:31 -08:00
committed by GitHub
parent 4059251c13
commit 58aa041db3
7 changed files with 22 additions and 6 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
stack_version: ['2.1.0']
stack_version: ['2.1.1']
steps:
- name: Checkout
+11 -3
View File
@@ -1,15 +1,23 @@
# CHANGELOG
Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
## [Unreleased]
## [2.1.1]
### Added
### Changed
### Deprecated
### Removed
### 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
## [2.0.1]
+1 -1
View File
@@ -24,4 +24,4 @@
# specific language governing permissions and limitations
# under the License.
__versionstr__ = "2.1.0"
__versionstr__ = "2.1.1"
+3 -1
View File
@@ -46,11 +46,13 @@ class AWSV4SignerAsyncAuth:
# create an AWS request object and sign it using SigV4Auth
aws_request = AWSRequest(
method=method,
url="".join([url, query_string]),
url=url,
data=body,
)
sig_v4_auth = SigV4Auth(self.credentials, self.service, self.region)
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
return dict(aws_request.headers.items())
+4
View File
@@ -80,6 +80,7 @@ class AWSV4SignerAuth(requests.auth.AuthBase):
aws_request = AWSRequest(
method=prepared_request.method.upper(),
url=url,
data=prepared_request.body,
)
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
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
@@ -78,3 +78,4 @@ class TestAsyncSigner(TestCase):
self.assertIn("Authorization", headers)
self.assertIn("X-Amz-Date", headers)
self.assertIn("X-Amz-Security-Token", headers)
self.assertIn("X-Amz-Content-SHA256", headers)
+1
View File
@@ -332,6 +332,7 @@ class TestUrllib3Connection(TestCase):
self.assertIn("Authorization", prepared_request.headers)
self.assertIn("X-Amz-Date", prepared_request.headers)
self.assertIn("X-Amz-Security-Token", prepared_request.headers)
self.assertIn("X-Amz-Content-SHA256", prepared_request.headers)
@pytest.mark.skipif(
sys.version_info < (3, 6), reason="AWSV4SignerAuth requires python3.6+"