Does Amazon S3 support HTTP request with basic authentication

前端 未结 8 857
予麋鹿
予麋鹿 2020-12-04 15:17

I would like to set up an Amazon S3 account, create a bucket, upload some data, and that this data will be available using HTTP GET with basic authentication

8条回答
  •  日久生厌
    2020-12-04 15:54

    This is now possible using CloudFront and Lambda@Edge (generally available since July 2017 in the us-east-1 region).

    1. Create a S3 bucket
    2. Setup a CloudFront distribution in-front of the bucket, restricting access to the bucket so that only CloudFront can access it directly
    3. Create a Lambda function, which will mimic Basic HTTP Auth handshake with the browser. Assign it to the CloudFront Viewer Request behavior.

    Here's the Lambda function: https://gist.github.com/lmakarov/e5984ec16a76548ff2b278c06027f1a4

    Here's an article with more details: https://medium.com/@lmakarov/serverless-password-protecting-a-static-website-in-an-aws-s3-bucket-bfaaa01b8666

提交回复
热议问题