Skip to content

Include request body of multipart/form-data requests into AWS4 signature #1120

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/authorizer/aws4.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,16 @@
return callback(hash.digest(digestEncoding));
}

// @todo: formdata body type requires adding new data to form instead of setting headers for AWS auth.
// @todo: formdata body type for S3 requires adding new data to form instead of setting headers for AWS auth.
// Figure out how to do that. See below link:
// AWS auth with formdata: https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-post-example.html
// For now, sign requests as other POST requests for use with API gateway and Lambda functions.
if (body.mode === RequestBody.MODES.formdata) {
formdataBody = bodyBuilder.formdata(body.formdata).body;
hash.update(formdataBody);

Check warning on line 80 in lib/authorizer/aws4.js

View check run for this annotation

Codecov / codecov/patch

lib/authorizer/aws4.js#L78-L80

Added lines #L78 - L80 were not covered by tests

return callback(hash.digest(digestEncoding));

Check warning on line 82 in lib/authorizer/aws4.js

View check run for this annotation

Codecov / codecov/patch

lib/authorizer/aws4.js#L82

Added line #L82 was not covered by tests
}

// ensure that callback is called if body.mode doesn't match with any of the above modes
return callback();
Expand Down