- 
                Notifications
    You must be signed in to change notification settings 
- Fork 947
Support for payload signing + chunked encoding in DefaultAwsV4HttpSigner #6466
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
Support for payload signing + chunked encoding in DefaultAwsV4HttpSigner #6466
Conversation
This commit adds support for SigV4 signing of async request payloads. In addition this commit moves the support for trailing checksums from HttpChecksumStage to the V4 signer implementation; this puts it in line with how sync chunked bodies are already handled.
- Rename to computeAndMoveContentLength - Rename variable to chunkedPayload - Fix javadocs - Sign payload only if non-null
Combine these two steps to improve performance by reducing memory allocations.
fcda677    to
    488b723      
    Compare
  
    3a9cb34    to
    e52ea62      
    Compare
  
            
          
                ...aws/src/main/java/software/amazon/awssdk/http/auth/aws/internal/signer/util/SignerUtils.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                ...ain/java/software/amazon/awssdk/http/auth/aws/internal/signer/AwsChunkedV4PayloadSigner.java
          
            Show resolved
            Hide resolved
        
              
          
                ...ain/java/software/amazon/awssdk/http/auth/aws/internal/signer/AwsChunkedV4PayloadSigner.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                ...ain/java/software/amazon/awssdk/http/auth/aws/internal/signer/AwsChunkedV4PayloadSigner.java
          
            Show resolved
            Hide resolved
        
              
          
                ...c/main/java/software/amazon/awssdk/core/internal/http/pipeline/stages/HttpChecksumStage.java
          
            Show resolved
            Hide resolved
        
              
          
                ...are/amazon/awssdk/http/auth/aws/internal/signer/chunkedencoding/ChunkedEncodedPublisher.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                ...ava/software/amazon/awssdk/http/auth/aws/crt/internal/signer/AwsChunkedV4aPayloadSigner.java
          
            Show resolved
            Hide resolved
        
              
          
                ...c/main/java/software/amazon/awssdk/core/internal/http/pipeline/stages/HttpChecksumStage.java
          
            Show resolved
            Hide resolved
        
      - Update variable naming - Throw if decoded content length not present - Throw if input request doesn't have content-length header
        
          
                ...va/software/amazon/awssdk/http/auth/aws/internal/signer/io/UnbufferedChecksumSubscriber.java
          
            Show resolved
            Hide resolved
        
              
          
                ...a/software/amazon/awssdk/http/auth/aws/internal/signer/util/LengthCalculatingSubscriber.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                ...aws/src/main/java/software/amazon/awssdk/http/auth/aws/internal/signer/util/SignerUtils.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                ...ain/java/software/amazon/awssdk/http/auth/aws/internal/signer/AwsChunkedV4PayloadSigner.java
          
            Show resolved
            Hide resolved
        
              
          
                ...va/software/amazon/awssdk/http/auth/aws/internal/signer/io/UnbufferedChecksumSubscriber.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | Are we planning to have intergration test on the full S3 async flow for this PR? Or we'll add that after consolidating the behavior and before merging to master | 
| 
 Did you have specific tests in mind? We have existing integration tests that exercise the async checksumming: services/s3/src/it/java/software/amazon/awssdk/services/s3/checksum/AsyncHttpChecksumIntegrationTest.java | 
        
          
                ...c/main/java/software/amazon/awssdk/http/auth/aws/internal/signer/DefaultAwsV4HttpSigner.java
          
            Show resolved
            Hide resolved
        
      | Nice, we might need to update the TODO comments here: Line 258 in 6f7f0e7 
 | 
| 
 Hmm that can't be addressed right now actually, same for the other TODO. AFAICT from the javadoc, it's expecting the body to be signed because the client is using an      /**
     * S3 clients by default don't do payload signing. But when http is used, payload signing is expected to be enforced. But
     * payload signing is not currently supported in async path (for both pre/post SRA signers).
     * However, this test passes, because of https://github
     * .com/aws/aws-sdk-java-v2/blob/38e221bd815af31a6c6b91557499af155103c21a/core/auth/src/main/java/software/amazon/awssdk/auth/signer/internal/AbstractAwsS3V4Signer.java#L279-L285.
     * Keeping this test enabled, to ensure moving to SRA Identity & Auth, does not break current behavior.
     * TODO: Update this test with right asserts when payload signing is supported in async.
     */ | 
| 
 Oh you are right, I misunderstood what this test does. | 
2da656f    to
    efa994b      
    Compare
  
    | 
 | 
5cbd30a
      into
      
  
    feature/master/sra-async-chunked-encoding
  
    | This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one. | 



Motivation and Context
Add support for payload signing of async streaming requests signed with SigV4 using default
AwsV4HttpSigner(usingAwsV4HttpSigner.create()). Note, requests using thehttpURI scheme will not be signed regardless of the value ofAwsV4FamilyHttpSigner.PAYLOAD_SIGNING_ENABLEDto remain consistent with existing behavior. This may change in a future release.Modifications
Testing
Screenshots (if appropriate)
Types of changes
Checklist
mvn installsucceedsscripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes.License