A developer is building a REST API in Amazon API Gateway. The API needs to validate JSON Web Tokens (JWTs) sent by clients who have authenticated using an Amazon Cognito User Pool. The developer wants to implement this security check with the least configuration effort and no additional custom code. Which authorization method is the most appropriate to meet these requirements?
- Configure an API Gateway Cognito User Pool authorizer by specifying the User Pool ID and client ID.Answer
- BCreate a custom Lambda authorizer that imports a JWT library to verify and decode the token signature.
- CSet up an Amazon Cognito Identity Pool to authenticate the requests and grant temporary IAM credentials to the API clients.
- DUse a Lambda proxy integration to forward the raw request headers and perform the token validation inside the backend Lambda function logic.
Answer
Configure an API Gateway Cognito User Pool authorizer by specifying the User Pool ID and client ID.
The correct option is configuring an API Gateway Cognito User Pool authorizer. This built-in authorizer natively validates JSON Web Tokens (JWTs) generated by Cognito User Pools, eliminating the need to write, test, or pay for custom Lambda authorizer code.
Step-by-Step Solution
Key Concept
API Gateway Cognito User Pools Authorizer