aws-samples / aws-samples/cloudfront-authorization-at-edge
[Question] Accessing S3 bucket from within the SPA?
- Dominant language
- TypeScript
- Stars
- 534
- Forks
- 165
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
Sorry if this is slightly off topic, but I was wondering if it is possible to access the private S3 bucket hosting the SPA, with a jquery `.get` function from within the SPA?
Background:
- I'm trying to setup authentication to access a private S3 bucket, and using this open source repository (https://github.com/rufuspollock/s3-bucket-listing) to list all items within the S3 bucket once authenticated. (I have also opened a ticket there https://github.com/rufuspollock/s3-bucket-listing/issues/101, where I go through some of the steps I've done).
- I've run the cloudformation template, and replaced the react SPA, with the `index.html` mentioned in the above ticket, and logging in works great, and I can nearly see the entire `index.html` page, but it doesn't display anything in the S3 bucket itself.
I have some theories about this, but wasn't sure who to ask, so hoping someone could point me in the right direction.
- In the [list.js](https://github.com/rufuspollock/s3-bucket-listing/blob/gh-pages/list.js#L122), it uses a `$.get(s3_rest_url)`, however this returns an empty string (from what I can tell), and I think this is due to the `list.js` not passing in the authentication tokens required to access the S3 bucket (in the same way the user needed to sign in to access the `index.html`).
If this is the case, would a solution be to download the cookies from the browser post logging by the user, in the `list.js` file and pass one of the auth tokens in the `$.get(s3_rest_url)` so that it can access the S3 bucket?
Please let me know if you need any more information, and any advice would be greatly appreciated!
Thank you.
Contributor guide
Research direction
Start by reviewing the CloudFormation setup, the replacement index.html, and list.js around the $.get(s3_rest_url) call. Compare the authentication flow with the request used to list the private S3 bucket; done would be a documented explanation or confirmed change showing whether the authenticated SPA can retrieve the bucket contents.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, javascript, jquery, react
- Domain
- authentication, cloud, frontend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 15/100