Skip to content

Commit 3a9cb34

Browse files
committed
Updates
1 parent 4b8b790 commit 3a9cb34

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

core/http-auth-aws/src/main/java/software/amazon/awssdk/http/auth/aws/internal/signer/DefaultAwsV4HttpSigner.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,15 @@ private static V4PayloadSigner v4PayloadAsyncSigner(
204204
throw new UnsupportedOperationException("Unsigned payload is not supported with event-streaming.");
205205
}
206206

207-
// Note: this check is done after we check if the request is eventstreaming, during which we just use the normal logic
208-
// as sync to determine if the body should be signed. If it's not eventstreaming, hen async needs to treat this request
209-
// as unsigned to maintain current behavior re: plain HTTP requests.
207+
// Note: this check is done after we check if the request is eventstreaming, during which we just use the same logic
208+
// as sync to determine if the body should be signed. If it's not eventstreaming, then async needs to treat this
209+
// request differently to maintain current behavior re: plain HTTP requests.
210+
boolean nonEvenstreamingPayloadSigning = isPayloadSigning;
210211
if (asyncShouldTreatAsUnsigned(request)) {
211-
isPayloadSigning = false;
212+
nonEvenstreamingPayloadSigning = false;
212213
}
213214

214-
if (useChunkEncoding(isPayloadSigning, isChunkEncoding, isTrailing || isFlexible)) {
215+
if (useChunkEncoding(nonEvenstreamingPayloadSigning, isChunkEncoding, isTrailing || isFlexible)) {
215216
return AwsChunkedV4PayloadSigner.builder()
216217
.credentialScope(properties.getCredentialScope())
217218
.chunkSize(DEFAULT_CHUNK_SIZE_IN_BYTES)

core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/http/pipeline/stages/AsyncSigningStage.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
import software.amazon.awssdk.http.auth.spi.signer.AsyncSignedRequest;
4444
import software.amazon.awssdk.http.auth.spi.signer.BaseSignedRequest;
4545
import software.amazon.awssdk.http.auth.spi.signer.HttpSigner;
46+
import software.amazon.awssdk.http.auth.spi.signer.PayloadChecksumStore;
47+
import software.amazon.awssdk.http.auth.spi.signer.SdkInternalHttpSignerProperty;
4648
import software.amazon.awssdk.http.auth.spi.signer.SignRequest;
4749
import software.amazon.awssdk.http.auth.spi.signer.SignedRequest;
4850
import software.amazon.awssdk.identity.spi.Identity;
@@ -88,11 +90,15 @@ public CompletableFuture<SdkHttpFullRequest> execute(SdkHttpFullRequest request,
8890
private <T extends Identity> CompletableFuture<SdkHttpFullRequest> sraSignRequest(SdkHttpFullRequest request,
8991
RequestExecutionContext context,
9092
SelectedAuthScheme<T> selectedAuthScheme) {
93+
// Should not be null, added by HttpChecksumStage for SRA signed requests
94+
PayloadChecksumStore payloadChecksumStore =
95+
context.executionAttributes().getAttribute(SdkInternalExecutionAttribute.CHECKSUM_STORE);
96+
9197
adjustForClockSkew(context.executionAttributes());
9298
CompletableFuture<? extends T> identityFuture = selectedAuthScheme.identity();
9399
return identityFuture.thenCompose(identity -> {
94100
CompletableFuture<SdkHttpFullRequest> signedRequestFuture = MetricUtils.reportDuration(
95-
() -> doSraSign(request, context, selectedAuthScheme, identity),
101+
() -> doSraSign(request, context, selectedAuthScheme, identity, payloadChecksumStore),
96102
context.attemptMetricCollector(),
97103
CoreMetric.SIGNING_DURATION);
98104

@@ -106,14 +112,16 @@ private <T extends Identity> CompletableFuture<SdkHttpFullRequest> sraSignReques
106112
private <T extends Identity> CompletableFuture<SdkHttpFullRequest> doSraSign(SdkHttpFullRequest request,
107113
RequestExecutionContext context,
108114
SelectedAuthScheme<T> selectedAuthScheme,
109-
T identity) {
115+
T identity,
116+
PayloadChecksumStore payloadChecksumStore) {
110117
AuthSchemeOption authSchemeOption = selectedAuthScheme.authSchemeOption();
111118
HttpSigner<T> signer = selectedAuthScheme.signer();
112119

113120
if (context.requestProvider() == null) {
114121
SignRequest.Builder<T> signRequestBuilder = SignRequest
115122
.builder(identity)
116123
.putProperty(HttpSigner.SIGNING_CLOCK, signingClock())
124+
.putProperty(SdkInternalHttpSignerProperty.CHECKSUM_STORE, payloadChecksumStore)
117125
.request(request)
118126
.payload(request.contentStreamProvider().orElse(null));
119127
authSchemeOption.forEachSignerProperty(signRequestBuilder::putProperty);
@@ -125,8 +133,10 @@ private <T extends Identity> CompletableFuture<SdkHttpFullRequest> doSraSign(Sdk
125133
AsyncSignRequest.Builder<T> signRequestBuilder = AsyncSignRequest
126134
.builder(identity)
127135
.putProperty(HttpSigner.SIGNING_CLOCK, signingClock())
136+
.putProperty(SdkInternalHttpSignerProperty.CHECKSUM_STORE, payloadChecksumStore)
128137
.request(request)
129138
.payload(context.requestProvider());
139+
130140
authSchemeOption.forEachSignerProperty(signRequestBuilder::putProperty);
131141

132142
CompletableFuture<AsyncSignedRequest> signedRequestFuture = signer.signAsync(signRequestBuilder.build());

0 commit comments

Comments
 (0)