A developer is building a smart-home mobile application that connects to a backend hosted on Amazon API Gateway. Users authenticate with the application through an Amazon Cognito User Pool, which provides a JSON Web Token (JWT) upon login. The developer needs to secure the API Gateway REST API by verifying these JWTs before forwarding requests to the backend services.
Which of the following is the most operationally efficient method to authorize API requests using these JWTs?
- AConfigure an Amazon Cognito Identity Pool authorizer on the Amazon API Gateway REST API.
- Configure a built-in Amazon Cognito User Pool authorizer on the Amazon API Gateway REST API.Answer
- CCreate a custom Amazon Lambda authorizer to decode and validate the Cognito JWTs.
- DEnable Amazon Lambda Proxy integration on Amazon API Gateway to validate the Cognito JWTs within the backend Lambda function.
Answer
Configure a built-in Amazon Cognito User Pool authorizer on the Amazon API Gateway REST API.
The correct option is to configure a built-in Amazon Cognito User Pool authorizer. API Gateway natively integrates with Cognito User Pools to validate JWT identity tokens without requiring custom code or additional Lambda invocations, making it the most operationally efficient choice.
Step-by-Step Solution
Key Concept
API Gateway built-in Cognito User Pool Authorizers