Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

API Gateway Lambda Authorizer for Basic HTTP Authentication

This pattern deploys an API Gateway REST API protected by a Lambda Authorizer supporting Basic HTTP Authentication.

Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the AWS Pricing page for details. You are responsible for any AWS costs incurred. No warranty is implied in this example.

Requirements

Deployment Instructions

  1. Clone the project to your local working directory

    git clone https://github.com/aws-samples/serverless-patterns
  2. Change the working directory to this pattern's directory

    cd apigw-lambda-authorizer-basic-cdk
  3. Install dependencies

    npm install
  4. Deploy the stack to your default AWS account and region. The output of this command should give you the HTTP API URL.

    cdk deploy

How it works

Using a Lambda Authorizer the credentials provided in the Authorization header are decoded using Base64 and verified in a mock database.

Testing

Run the following commands using the API endpoint.

  1. Positive testing - Check the output for a hello world message.

    curl -u user1:password1 '<protected api endpoint>'
  2. Negative testing - Check the output for a not authorized error message.

    curl -u user1:wrongPassword '<protected api endpoint>'

Cleanup

Run the given command to delete the resources that were created. It might take some time for the CloudFormation stack to get deleted.

cdk destroy

Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.

SPDX-License-Identifier: MIT-0