Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

made custom headers be available to async aws signer #863

Merged
merged 4 commits into from
Dec 1, 2024

Conversation

brunomurino
Copy link
Contributor

Description

When creating an Async client, you can now pass a custom 'host' header that will be used for signing the AWS request, if using AWS authentication. This allows accessing OpenSearch via SSH/SSM tunnel, since when doing so the local port of OS would be, most of the time, 443 which is protected.

Issues Resolved

Closes #184

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link

codecov bot commented Nov 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.45%. Comparing base (ba715b9) to head (6ad3178).
Report is 76 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #863      +/-   ##
==========================================
- Coverage   71.95%   70.45%   -1.50%     
==========================================
  Files          91      125      +34     
  Lines        8001     9311    +1310     
==========================================
+ Hits         5757     6560     +803     
- Misses       2244     2751     +507     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@brunomurino
Copy link
Contributor Author

@dblock Indeed the Async transport wasn't leveraging the custom headers passed, so I added that following how it was done in the sync version. Also added a couple of tests.

I couldn't find where to add public documentation. I'm happy to add some bits if you point me to the right place.

Also, the coverage test is failing but I'm not sure it's due to my changes?

@brunomurino
Copy link
Contributor Author

Added some docs in the existing auth.md guide

@dblock
Copy link
Member

dblock commented Dec 1, 2024

Also, the coverage test is failing but I'm not sure it's due to my changes?

Likely not. Would be nice if someone got to the bottom of it.

Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this!

Two nice to have things for a future PR if you want to improve it.

  1. _fetch_url is common for 2 signers, refactor either into a base class or a utility
  2. The test "knows" that there's an internal _fetch_url which is an antipattern, it should be doing the signing and ensuring the signer is called with a different URL - I think we have other tests that use a mock signer already if you want to copy from

@dblock dblock merged commit 6f761ab into opensearch-project:main Dec 1, 2024
32 of 33 checks passed
@brunomurino
Copy link
Contributor Author

brunomurino commented Dec 1, 2024 via email

@brunomurino
Copy link
Contributor Author

@dblock Regarding the test, would you be opposed to using something like:

with patch("botocore.awsrequest.AWSRequest", side_effect=AWSRequest) as mock_AWSRequest:

to see if the right argument was passed? would that still be an antipattern?

@dblock
Copy link
Member

dblock commented Dec 2, 2024

I think that makes things a lot simpler!

@brunomurino
Copy link
Contributor Author

Made changes here #866

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Allow setting alternate host header (with port) in AWSV4SignerAuth
2 participants