Member-only story
How to implement HTTP basic auth on Cloudfront?
What is basic auth?
Basic access authentication is a method for an HTTP user agent (e.g. a web browser) to provide a user name and password when making a request. In basic HTTP authentication, a request contains a header field in the form of
Authorization: Basic <credentials>, where credentials is the Base64 encoding of ID and password joined by a single colon:.It was originally implemented by Ari Luotonen at CERN in 1993[1] and defined in the HTTP 1.0 specification in 1996.[2] It is specified in RFC 7617 from 2015, which obsoletes RFC 2617 from 1999.
source: wiki
Where can I use this?
This type of implementation on cloudfront is commonly employed in the following scenarios:
- Web applications intended for limited visibility during the development phase, targeting a specific group
- Web applications that should remain inaccessible to bots and are intended solely for internal use
How to implement it?
We will make use of Lambda’ edge “origin request” lifecycle function.
Which means, that just before the cloudfront passes on the request details to origin, it will run an authentication check via the…









