I got my application written in Flask (Python 3.6) and running on EB.
I need to implement content editor which will allow to upload files on server and I would like to store them on s3. Most of uploaded files will be available on after login in my app.
Question is how to handle security of such files?
Should I use my application as middleware and check if user is logged and if so, then download file from S3 in my backend and return it to user as standard Flask response?
Or better idea is to generate presigned urls with expiration date?
Problem with presigned urls is that I will lose browser-side caching for my files, which I would like to keep (most of files are images, so it's unnecessary to redownload it every time).
Also second problem is that this url is not bind in any way with user logged in my app, so basically this presigned url can be used by anyone until it expires.
Right now I got legacy code implemented in first way: