Fix SigV4 Initial Message support #4400
Open
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.
Motivation and Context
#4397
The SigV4 support for event streams did not unframe the message before trying to read the initial event. This mean that if an initial event was sent, it ended up going to the unmarshaller where it subsequently caused an error.
Description
The previous attempt at this wrapped the
Unmarshallerwith aSigV4Unmarshaller. This didn't quite work in practice.Previously, SigV4 support worked by transforming the receiver type:
This approach had a fundamental flaw: the receiver's internal buffering logic didn't understand SigV4 envelopes. When it buffered a message, it would buffer the unwrapped inner message, losing the signature.
The new design introduces
SigV4Receiver<T, E>as a wrapper aroundReceiver<SignedEvent<T>, SignedEventError<E>>.This allows us to both capture the initial message signature (which will be required to actually verify it) as well as providing a clean place to handle the details.
This also meant that I could back out all the previous customization changes, so those are now deleted.
Testing
The tests were cleaned up. Most were moved to a rstest to handle all the individual test behaviors.
Checklist
.changelogdirectory, specifying "client," "server," or both in theapplies_tokey..changelogdirectory, specifying "aws-sdk-rust" in theapplies_tokey.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.