-
Notifications
You must be signed in to change notification settings - Fork 183
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
Fix AWS SigV4 on delete requests when using AWS SDK's Apache client #1256
base: main
Are you sure you want to change the base?
Fix AWS SigV4 on delete requests when using AWS SDK's Apache client #1256
Conversation
The AWS SDK's Apache client implementation does not send the `Content-Length` header on DELETE requests, but the header is being set before calculating the signature. This causes the Amazon OpenSearch Service to report an incorrect signature as it does not receive the header value needed to validate the signature. `Content-Length` is somewhat unreliable to include in the signature calculation, but the AWS SDK doesn't allow configuring which headers to ignore in signature calculation. As such we must move setting the header to after the signature is calculated. Additionally moves to the supported `AwsV4HttpSigner` as `Aws4Signer` is now deprecated: https://github.com/aws/aws-sdk-java-v2/blob/88abec27e7d5d35b21545c7e05875a7cc3d0f46e/core/auth/src/main/java/software/amazon/awssdk/auth/signer/Aws4Signer.java Signed-off-by: Thomas Farr <[email protected]>
Signed-off-by: Thomas Farr <[email protected]>
Signed-off-by: Thomas Farr <[email protected]>
"awsSdk2SupportCompileOnly"("software.amazon.awssdk", "sdk-core", "[2.21,3.0)") | ||
"awsSdk2SupportCompileOnly"("software.amazon.awssdk", "auth", "[2.21,3.0)") | ||
"awsSdk2SupportCompileOnly"("software.amazon.awssdk", "http-auth-aws", "[2.21,3.0)") | ||
testImplementation("software.amazon.awssdk", "sdk-core", "[2.21,3.0)") |
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.
I believe we should be using awsSdk2SupportTestImplementation
here:
testImplementation("software.amazon.awssdk", "sdk-core", "[2.21,3.0)") | |
awsSdk2SupportTestImplementation("software.amazon.awssdk", "sdk-core", "[2.21,3.0)") |
@@ -85,6 +87,7 @@ public class AwsSdk2Transport implements OpenSearchTransport { | |||
private final String signingServiceName; | |||
private final Region signingRegion; | |||
private final JsonpMapper defaultMapper; | |||
@Nonnull |
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.
No particular take on that, but I believe all these fields should not be null.
} | ||
|
||
// Apache 2.0 | ||
testImplementation("org.wiremock", "wiremock", "3.9.2") |
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.
Nothing against wiremock
, but we already have all needed pieces:
HttpServer
that comes from HttpCore 5 (example https://github.com/apache/httpcomponents-core/blob/master/httpcore5-reactive/src/test/java/org/apache/hc/core5/reactive/examples/ReactiveFullDuplexServerExample.java)- since we run test with JDK-11, we could use
com.sun.net.httpserver.HttpServer
that comes with standard library (see please https://docs.oracle.com/en/java/javase/11/docs/api/jdk.httpserver/com/sun/net/httpserver/HttpServer.html)
Description
The AWS SDK's Apache client implementation does not send the
Content-Length
header on DELETE requests, but the header is being set before calculating the signature. This causes the Amazon OpenSearch Service to report an incorrect signature as it does not receive the header value needed to validate the signature.Content-Length
is somewhat unreliable to include in the signature calculation, but the AWS SDK doesn't allow configuring which headers to ignore in signature calculation. As such we must move setting the header to after the signature is calculated.Additionally moves to the supported
AwsV4HttpSigner
asAws4Signer
is now deprecated: https://github.com/aws/aws-sdk-java-v2/blob/88abec27e7d5d35b21545c7e05875a7cc3d0f46e/core/auth/src/main/java/software/amazon/awssdk/auth/signer/Aws4Signer.javaIssues Resolved
Fixes #712
Fixes #521
Fixes #503
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.