Skip to content
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

feat: Add option to generate pre-signed URL with expiration time #180

Merged
merged 20 commits into from
May 12, 2023

Conversation

andrewalc
Copy link
Contributor

danielsanfr and others added 16 commits November 17, 2020 00:41
Signed-off-by: Daniel San <[email protected]>
Signed-off-by: Daniel San <[email protected]>
Signed-off-by: Daniel San <[email protected]>
Signed-off-by: Daniel San <[email protected]>
…peration in the getSignedUrl function

Signed-off-by: Daniel San <[email protected]>
@penchef
Copy link

penchef commented Mar 31, 2023

can't wait for it ! 😱

@mtrezza mtrezza requested a review from a team April 3, 2023 23:00
@codecov
Copy link

codecov bot commented Apr 21, 2023

Codecov Report

Patch coverage: 96.29% and project coverage change: -0.16 ⚠️

Comparison is base (73b17e4) 95.72% compared to head (fadb515) 95.56%.

❗ Current head fadb515 differs from pull request most recent head 807e51c. Consider uploading reports for the commit 807e51c to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #180      +/-   ##
==========================================
- Coverage   95.72%   95.56%   -0.16%     
==========================================
  Files           2        2              
  Lines         187      203      +16     
  Branches       41       43       +2     
==========================================
+ Hits          179      194      +15     
- Misses          8        9       +1     
Impacted Files Coverage Δ
index.js 95.08% <95.65%> (-0.38%) ⬇️
lib/optionsFromArguments.js 96.29% <100.00%> (+0.19%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@mtrezza mtrezza changed the title Add option to generate a presigned url with a expiration time feat: Add option to generate pre-signed URL with expiration time Apr 22, 2023
@parse-github-assistant
Copy link

Thanks for opening this pull request!

  • ❌ Please link an issue that describes the reason for this pull request, otherwise your pull request will be closed. Make sure to write it as Closes: #123 in the PR description, so I can recognize it.

@@ -93,6 +95,8 @@ const optionsFromArguments = function optionsFromArguments(args) {
options = fromEnvironmentOrDefault(options, 'baseUrlDirect', 'S3_BASE_URL_DIRECT', false);
options = fromEnvironmentOrDefault(options, 'signatureVersion', 'S3_SIGNATURE_VERSION', 'v4');
options = fromEnvironmentOrDefault(options, 'globalCacheControl', 'S3_GLOBAL_CACHE_CONTROL', null);
options = fromEnvironmentOrDefault(options, 'presignedUrl', 'S3_PRESIGNED_URL', false);
options = fromEnvironmentOrDefault(options, 'presignedUrlExpires', 'S3_PRESIGNED_URL_EXPIRES', 900);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you get to 900? Is this a random value you chose?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the previous PR owner figured 15 mins was a good default value, should this be changed?

Copy link
Member

@mtrezza mtrezza Apr 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the AWS API use a default value if none is supplied?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#getSignedUrl-property

Oh it does look like s3's getSignedURL defaults Expires to 900 seconds

Options Hash (params):

Expires (Integer) — default: 900 — the number of seconds to expire the pre-signed URL operation in. Defaults to 15 minutes.

Copy link
Member

@mtrezza mtrezza May 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we don't have to set a default value, as the S3 SDK will set that, right? If so, I'd suggest to only send a value to the S3 SDK if the Parse Server option is set, otherwise not send anything and let the default value of the SDK apply. You could add a line to the Parse Server option table in the README that if no value is set, the AWS S3 SDK default value applies.

spec/test.spec.js Show resolved Hide resolved
@andrewalc andrewalc requested a review from mtrezza April 25, 2023 16:28
@jimnor0xF
Copy link

Wouldl love this!

Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, let's wait for the CI to pass and I think we can merge this.

@mtrezza mtrezza merged commit d92363d into parse-community:master May 12, 2023
@mtrezza mtrezza linked an issue May 12, 2023 that may be closed by this pull request
parseplatformorg pushed a commit that referenced this pull request May 12, 2023
# [2.1.0](2.0.2...2.1.0) (2023-05-12)

### Features

* Add option to generate pre-signed URL with expiration time ([#180](#180)) ([d92363d](d92363d))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 2.1.0

@dblythy
Copy link
Member

dblythy commented May 17, 2023

Nice work @danielsanfr and @andrewalc!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Presigned URLs
7 participants