https://github.com/kkpoon/lambda-edge-basic-auth
Basic Authentication at AWS Lambda@Edge
https://github.com/kkpoon/lambda-edge-basic-auth
aws-cloudfront aws-lambda basic-authentication lambda-edge
Last synced: 10 months ago
JSON representation
Basic Authentication at AWS Lambda@Edge
- Host: GitHub
- URL: https://github.com/kkpoon/lambda-edge-basic-auth
- Owner: kkpoon
- License: mit
- Created: 2017-12-27T07:41:06.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-06-05T02:30:22.000Z (over 6 years ago)
- Last Synced: 2025-02-01T03:28:43.360Z (12 months ago)
- Topics: aws-cloudfront, aws-lambda, basic-authentication, lambda-edge
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lambda-edge-basic-auth
This is a simple implementation of Basic Authentication in AWS Lambda@Edge for controlling access of CloudFront distribution.
To use this lambda, you have to config as follow
1. Deploy this lambda function in `us-east-1`. The function MUST be deployed in `us-east-1` for lambda@edge.
2. Use the following `AssumeRole` for this lambda execution role, edit in IAM / Roles / Your Lambda Execution Role / Trust Relationship
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
},
{
"Effect": "Allow",
"Principal": {
"Service": "edgelambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
```
3. Publish a version of the lambda
4. In CloudFront, config the distribution **Lambda Function Associations**, set the **CloudFront Event** to **Viewer Request**, set your versioned lambda ARN, and leave **Include Body** unchecked.