-
Notifications
You must be signed in to change notification settings - Fork 176
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
Added support for AWS Sigv4 for UrlLib3. #547
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a732d44
WIP: Added support for AWS Sigv4 for UrlLib3.
dblock e18b703
Refactored common implementation.
dblock fd9fa73
Added sigv4 samples.
dblock 6500c2b
Updated CHANGELOG.
dblock f8f2b62
Add documentation.
dblock ae1ebe1
Use the correct class in tests.
dblock df5b29b
Renamed samples.
dblock 8d5aeb0
Split up requests and urllib3 unit tests.
dblock ee4517d
Rename AWSV4Signer.
dblock cb76874
Clarified documentation of when to use Urllib3AWSV4SignerAuth vs. Req…
dblock 9e6b9aa
Move fetch_url inside the signer class.
dblock e916060
Added unit test for Urllib3AWSV4SignerAuth adding headers.
dblock 284a5fd
Added unit test for signing to include query string.
dblock File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## AWS SigV4 Samples | ||
|
||
Create an OpenSearch domain in (AWS) which support IAM based AuthN/AuthZ. | ||
|
||
``` | ||
export AWS_ACCESS_KEY_ID= | ||
export AWS_SECRET_ACCESS_KEY= | ||
export AWS_SESSION_TOKEN= | ||
export AWS_REGION=us-west-2 | ||
|
||
export SERVICE=es # use "aoss" for OpenSearch Serverless. | ||
export ENDPOINT=https://....us-west-2.es.amazonaws.com | ||
|
||
poetry run aws/search-urllib.py | ||
``` | ||
|
||
This will output the version of OpenSearch and a search result. | ||
|
||
``` | ||
opensearch: 2.3.0 | ||
{'director': 'Bennett Miller', 'title': 'Moneyball', 'year': 2011} | ||
``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RequestsAWSV4SignerAuth
returns prepared request whileUrllib3AWSV4SignerAuth
returns the headers, should we keep them consistent?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
requests
library expect a callable that derives fromrequests.auth.AuthBase
and receives arequest
object. It's called inside the requests library.The urllib3 library doesn't support such an interface. It actually splits the client constructor and exposes a
perform_request
method. That's where we have the method, URL, and body, and call auth. There's no "request" object here.We could make a similar interface to
AuthBase
for urllib3, but it cannot be the same interface because that one exists in the requests library. Since these signer classes aren't interchangeable at all, they don't need to derive from the same class, and I already moved the common parts intoAWSV4Signer
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, thank you!