Home   tech  

do we need to store presigned urls from aws s3 in database ?

We generally do not need to store presigned URLs in a database because they are meant to be generated on demand and have a built-in expiration mechanism. Storing them in a database would introduce unnecessary complexity and storage overhead without providing significant benefits. Here's why:

Temporary Nature

Presigned URLs are temporary by nature and are intended to expire after a short period. The expiration time is specified when the URL is generated, and after this time, the URL automatically becomes invalid and cannot be used to access the resource.

Generation on Demand

Presigned URLs are typically generated in response to a specific request by a user who has been authenticated and authorized to access the resource. This approach ensures that only users with the correct permissions at the time of the request can access the resource, enhancing security.

No State Management Required

Since presigned URLs expire automatically and are tied to the specific conditions under which they were generated (such as the intended operation, resource, and expiration time), there is no need to track their state or manage their lifecycle beyond their use in the application flow.

Efficiency and Scalability

Generating presigned URLs on the fly, as needed, is efficient and scalable. It avoids the overhead of writing to and reading from a database, which would be unnecessary given the transient nature of presigned URLs. This approach also simplifies the architecture of your application.

Handling Expiration

Instead of storing presigned URLs and tracking their expiration in a database, your application should be designed to generate a new presigned URL whenever a user needs access to a resource again after the previous URL has expired. This can be done automatically by the application logic, ensuring that users have seamless access to resources without manual intervention.

Security Consideration

Not storing presigned URLs also means there's no centralized repository of active links to your resources, reducing the risk of unauthorized access if the database is compromised.

Published on: Feb 29, 2024, 03:31 AM  
 

Comments

Add your comment