feat(s3): SigV4 pre-signed URL generation#80
Draft
Im5tu wants to merge 1 commit into
Draft
Conversation
Add IRequestPresigner (query-string SigV4 signing, UNSIGNED-PAYLOAD) to Goa.Clients.Core, and PresignGetObjectAsync / PresignPutObjectAsync to the S3 client. This lets object bytes transfer directly to/from S3 via a time-limited URL instead of being proxied through the caller (e.g. off the 6 MB Lambda invoke limit). - GET presign supports response-content-type/-disposition overrides - PUT presign can bind an exact content-length to cap upload size - Session tokens are included and signed; expiry clamped to the 7-day max - Reserved X-Amz-* query params and the host header are rejected from caller input; signed header values are whitespace-normalized per spec Correctness is proven by a deterministic known-answer test reproducing the AWS-documented example signature; LocalStack round-trip integration tests cover end-to-end upload/download and response-header overrides.
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Adds AWS SigV4 pre-signed URL generation to the S3 client so object bytes can transfer directly to/from S3 via a time-limited URL, instead of being proxied through the calling application. The motivating case: moving large uploads/downloads off the ~6 MB AWS Lambda synchronous invoke limit.
Changes
Goa.Clients.Core: new publicIRequestPresigner+PresignParameters, implemented by an internalRequestPresignerthat produces query-string SigV4 signatures (X-Amz-Algorithm/Credential/Date/Expires/SignedHeaders/Security-Token/Signature) using theUNSIGNED-PAYLOADcontent hash. Registered inAddGoaService.Goa.Clients.S3:IS3Client.PresignGetObjectAsyncandPresignPutObjectAsync, reusing the existingBuildObjectUri/ValidateBucketAndKeyso the signed path matches the byte-exact S3 key encoding used by the header-signing path.response-content-type/response-content-dispositionoverrides (signed).ContentLengthbinding — signscontent-lengthso S3 rejects a differently-sized body, capping upload size.Safety / correctness
X-Amz-*query params and thehostheader are rejected (they are produced and signed internally); signed header values are whitespace-normalized per spec.IsAotCompatible=truewith warnings-as-errors.Tests
aeeed9bb…), independently cross-checked — genuine proof of the canonicalization, string-to-sign, signing-key, and encoding. Also covers session-token encoding, extra-query-param encoding, expiry clamp, whitespace collapse, and the reserved-name guards. All passing.response-content-dispositionoverride check and a dot-segment key rejection. (Not run in the authoring environment — no Docker; runs in CI.)Notes