critical fix: Image attachments return 403#1231
critical fix: Image attachments return 403#1231Aryan-Verma-999 wants to merge 3 commits intoRocketChat:developfrom
Conversation
|
Hey @Spiral-Memory, I pushed the fix for the image preview 403. While testing, I noticed a separate issue where message history isn’t loading. I’m opening an issue #1232 for that now and looking into a fix. |
|
I didn't get the reason. Why specifically do we need to wrap it in useAuth? Why is it not working? Can you provide an RCA? |
|
the actual issue is that image attachments are loaded through /file-upload/... as browser asset requests, not through our normal authenticated API calls. Our API requests work because they send X-Auth-Token and X-User-Id, but the image request itself does not include those headers, so Rocket.Chat treats it as unauthenticated and returns 403. so the fix is really about making media URLs use the current authenticated session. A hook/shared auth helper is just one way to keep that in sync. |
|
Understood, but the current approach seems risky since it exposes the token in query parameters, and manually verifying the RC host doesn’t feel secure. A better solution might be to use an interceptor pattern, like a service worker or fetch the blob directly in React by including headers and then generate an object URL and use that url to display the place. |
|
got it, updating the approach to fetch the blob with auth headers and generate an object URL instead that avoids token exposure in query params entirely. Will push the updated fix shortly |
|
hey @Spiral-Memory , i need your advice on this issue is that protected images are served from /file-upload/..., and when EmbeddedChat is running cross-origin, fetching those files with auth headers triggers a CORS preflight. That route does not seem to allow this flow, so the request fails before we can even create the blob URL. so the blob approach does not look viable here. |
|
Hey @Spiral-Memory, |
|
Hey, this looks good @Aryan-Verma-999. Or are you talking about the API package in EmbeddedChat? (That's not a server; it's part of the EmbeddedChat frontend only.) |
|
Or you're saying, the developers has to provide a proxy url to store it? |
|
yeah, since EmbeddedChat is just a frontend widget, it can't store secure cookies itself. we can just expose a |
fix: Image attachments return 403 added Rc auth tokens to image URLs
Acceptance Criteria fulfillment
Fixes #1229
PR Test Details
Note: The PR will be ready for live testing at https://rocketchat.github.io/EmbeddedChat/pulls/pr-1231 after approval. Contributors are requested to replace
<pr_number>with the actual PR number.