Advertisement
Intermediate AWS, Amazon API Gateway

How does API Gateway handle authentication and authorization for incoming requests?

Short answer

API Gateway supports multiple authorization methods including IAM based permissions, Amazon Cognito user pools for managing app users, and custom Lambda authorizers that let you write your own logic to validate tokens such as JSON Web Tokens before allowing a request to reach…

Save AWS mock interview
Advertisement
AModel answer
API Gateway supports multiple authorization methods including IAM based permissions, Amazon Cognito user pools for managing app users, and custom Lambda authorizers that let you write your own logic to validate tokens such as JSON Web Tokens before allowing a request to reach the backend.
Example

aws apigateway create-authorizer --rest-api-id abc123 --name 'MyAuthorizer' --type TOKEN --authorizer-uri arn:aws:lambda:us-east-1:123456789012:function:authFunction

Real-world example
A mobile banking app uses a Lambda authorizer that checks a customer's login token on every API call, rejecting the request immediately if the token is invalid or expired before it ever reaches the backend service.
Likely follow-ups
  • What is the difference between a Lambda authorizer and Cognito user pool authorization?
  • How do you secure an API Gateway endpoint using API keys?
Related topics