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

Storage.get() url expires earlier than established #9346

Closed
3 tasks done
gzimbron opened this issue Dec 10, 2021 · 3 comments
Closed
3 tasks done

Storage.get() url expires earlier than established #9346

gzimbron opened this issue Dec 10, 2021 · 3 comments
Assignees
Labels
documentation Related to documentation feature requests good first issue Good for newcomers Storage Related to Storage components/category

Comments

@gzimbron
Copy link

Before opening, please confirm:

JavaScript Framework

Not applicable

Amplify APIs

Storage

Amplify Categories

storage

Environment information


  System:
    OS: macOS 12.0.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 158.28 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node
    npm: 8.1.1 - ~/.nvm/versions/node/v14.18.1/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Browsers:
    Chrome: 96.0.4664.93
    Safari: 15.1
  npmPackages:
    @sveltejs/adapter-static: ^1.0.0-next.21 => 1.0.0-next.21 
    @sveltejs/kit: v1.0.0-next.201 => 1.0.0-next.201 
    aws-amplify: ^4.3.8 => 4.3.8 
    axios: ^0.24.0 => 0.24.0 (0.21.4)
    firebase: ^9.5.0 => 9.5.0 
    firebase/analytics:  undefined ()
    firebase/app:  undefined ()
    firebase/app-check:  undefined ()
    firebase/auth:  undefined ()
    firebase/auth/cordova:  undefined ()
    firebase/auth/react-native:  undefined ()
    firebase/compat:  undefined ()
    firebase/compat/analytics:  undefined ()
    firebase/compat/app:  undefined ()
    firebase/compat/app-check:  undefined ()
    firebase/compat/auth:  undefined ()
    firebase/compat/database:  undefined ()
    firebase/compat/firestore:  undefined ()
    firebase/compat/functions:  undefined ()
    firebase/compat/messaging:  undefined ()
    firebase/compat/performance:  undefined ()
    firebase/compat/remote-config:  undefined ()
    firebase/compat/storage:  undefined ()
    firebase/database:  undefined ()
    firebase/firestore:  undefined ()
    firebase/firestore/lite:  undefined ()
    firebase/functions:  undefined ()
    firebase/messaging:  undefined ()
    firebase/messaging/sw:  undefined ()
    firebase/performance:  undefined ()
    firebase/remote-config:  undefined ()
    firebase/storage:  undefined ()
    svelte: ^3.44.0 => 3.44.2 
    sveltestrap: ^5.6.3 => 5.6.3 
    ~TODO~:  0.0.1 
  npmGlobalPackages:
    @aws-amplify/cli: 7.6.2
    aws-cli: 0.0.2
    firebase-tools: 9.23.0
    npm: 8.1.1

Describe the bug

When i generate url with Storage.get and I established expiration at 680400, url expires earlier, sometimes in hours

example signed url obtained:

https://viozon-storage-d19ugirv7c9inm182828-dev.s3.us-east-1.amazonaws.com/public/usuarios-1d8b6107-e518-498c-bcf3-459064d80dd1?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=ASIAVDNEQ3XVMEQSC5DN%2F20211210%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211210T151410Z&X-Amz-Expires=604800&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEBgaCXVzLWVhc3QtMSJHMEUCIQDi3In6cRrIaWhODHc%2FUj4R9FGZKSVnFfXEc9ZGZgHkPAIgZ05waAr3OckW4nUsXz7rYMqpZ2YZJMw7tYtH9%2BdmQL4qzQQI8P%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAAGgwzNTA5MjE3NDM4NTAiDIaCS1ljb06ZcMeE2CqhBHgk5eOfzolDX7hJz4nU8Ddg0ooe%2BMFDB1FrBoOCqhnPv0ITZwyAUQ0QEn2h1Qq9Ic65CHPS2kKWUadXpRmjqjTJz0OgPf7rYjN%2B1pPrISqCLYMyFxTHekhIdNBKMeiT4aAl2cRwhskIOxLLNL%2F89EJ8%2FzcAsC%2FxtMcwSLxA1BBDlgqdkUXYdhZzUYafaBUn33NYZ26yh88C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macOS%2F10.15.7%20lang%2Fjs%20md%2Fbrowser%2FChrome_96.0.4664.93%20api%2Fs3%2F3.6.1%20aws-amplify%2F4.3.7_js&x-id=GetObject

Expected behavior

Expected to generate url that expire in 7 days

Reproduction steps

1.- Storage.get the file
2.- save signed url
3.- url expires earlier than established

Code Snippet

imgurl = await Storage.get(imagekey, {
        expires: 60 * 60 * 24 * 7,
 });

Log output

// Put your logs below this line


aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

@chrisbonifacio chrisbonifacio self-assigned this Dec 10, 2021
@chrisbonifacio chrisbonifacio added Storage Related to Storage components/category pending-triage Issue is pending triage labels Dec 10, 2021
@evcodes evcodes added the good first issue Good for newcomers label Dec 15, 2021
@ErickGHo
Copy link

ErickGHo commented Dec 17, 2021

Sounds like the IAM role session expires which causes this. https://aws.amazon.com/premiumsupport/knowledge-center/presigned-url-s3-bucket-expiration/

My idea: Storage.get documentation can be modified to reflect these limits, and if the user really needs access to longer times - then developers can create an IAM user and create a apig+lambda endpoint to generate a longer signed url using the iam user's credentials. Any other feasible solution?

@arundna arundna assigned chrisbonifacio and unassigned vyomr13 May 9, 2022
@stocaaro stocaaro added feature-request Request a new feature and removed feature-request Request a new feature labels Jun 1, 2022
@chrisbonifacio chrisbonifacio added the bug Something isn't working label Jun 30, 2022
@ahilashsasidharan
Copy link

ahilashsasidharan commented Jun 30, 2022

I created a test app using react with the close to the latest packages and was able to reproduce the issue when an authenticated user signs in, uploads a photo, and creates a link as well as when an unauthenticated users does this as well. It seems that the max duration of the link created was 1 hour based on two test uploads and duration of the corresponding links created before they expired. This matches up with the maximum duration of when some AWS STS tokens expire. I've created two docs with my reproduction attempts, results and relevant documentation here:
https://docs.google.com/document/d/1IfjRRGoQ0tNtdvPxvHD9hp5QL3GoyRsNEtTUtE3jgwE/edit?usp=sharing
https://docs.google.com/document/d/1Z03add9Gt_uyrhei20jRUMsSVNbjet7eakXMvjNB0KQ/edit?usp=sharing .

@chrisbonifacio chrisbonifacio removed the pending-triage Issue is pending triage label Jul 6, 2022
@chrisbonifacio chrisbonifacio moved this from To do to Done in MLH Fellows Summer 2022 Jul 6, 2022
@nadetastic nadetastic self-assigned this Mar 14, 2023
@nadetastic nadetastic added documentation Related to documentation feature requests and removed bug Something isn't working labels Jun 2, 2023
@nadetastic
Copy link
Contributor

Hi @ahilashsasidharan , following up here. As you mentioned, the expiration time of the pre-signed url is dependent on the session and will max out at 1 hour. I've updated the documentation to reflect this and will close out this issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Related to documentation feature requests good first issue Good for newcomers Storage Related to Storage components/category
Development

No branches or pull requests

8 participants