Skip to content

Instantly share code, notes, and snippets.

@twoBoots
Created July 6, 2018 03:49
Show Gist options
  • Select an option

  • Save twoBoots/ead4e97229b7008e4ffefadb263f549b to your computer and use it in GitHub Desktop.

Select an option

Save twoBoots/ead4e97229b7008e4ffefadb263f549b to your computer and use it in GitHub Desktop.
API Gateway HTTP basic auth using Lambda@Edge
exports.handler = (event, context, done) => {
const response = event.Records[0].cf.response;
const headers = response.headers;
if(headers['edge-www-authenticate']) {
headers['www-authenticate'] = [{key: 'WWW-Authenticate', value: 'Basic realm="Secure Area"'}];
delete headers['edge-www-authenticate'];
}
done(null, response);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment