filestash icon indicating copy to clipboard operation
filestash copied to clipboard

[bug] Sharing w/ S3 + direct middleware produces 403

Open Haarolean opened this issue 1 year ago • 3 comments

Description of the bug

When using S3 as a backend and direct middleware sharing doesn't work, every link has 403 as a result. Looks like this: Oops! AccessDenied: Access Denied. status code: 403, request id: 174757DA33D49990, host id: Request: http://host/api/files/ls?path=%2F&share=Imr5jVL gives 500 with this response body: {"status":"error","message":"AccessDenied: Access Denied.\n\tstatus code: 403, request id: 174757DA33D49990, host id: "}

Step by step instructions to reproduce the bug

  1. Set up S3
  2. Set up direct middleware
  3. Share a link

Logs (DEBUG level):

filestash    | 2023/02/26 10:31:13 HTTP 200 POST    1.6ms /api/share/e9CkP4k/proof
filestash    | 2023/02/26 10:31:13 HTTP 200 GET    0.2ms /admin/api/session
filestash    | 2023/02/26 10:31:14 SYST DEBUG ls::backend 'AccessDenied: Access Denied.
filestash    | 	status code: 403, request id: 17475935D8185F41, host id: '
filestash    | 2023/02/26 10:31:14 HTTP 500 GET    6.1ms /api/files/ls?path=%2F&share=e9CkP4k
filestash    | 2023/02/26 10:31:15 HTTP 304 GET    0.2ms /sw_cache.js

Haarolean avatar Feb 26 '23 10:02 Haarolean

Welp, I figured this out. That required some network debugging, s3 tracing, and reading the code of the app. It turns out, you have to put a slash at the end of the path in your middleware if it's not empty. I wanted to give access to root w/ bucket "public", so I did put "/public" as the path, that was the cause of the issue, all the paths became "publicactualfilename", without a slash. That's absolutely not obvious behavior, can we do something with it?

Haarolean avatar Mar 03 '23 05:03 Haarolean

I can't replicate this on my own. If you can reproduce this from the demo.filestash.app and publish all the steps in here, I'll make up a fix for it

mickael-kerjean avatar Mar 30 '23 14:03 mickael-kerjean

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 18 '23 14:06 stale[bot]