Question

Difficulty: MediumAPI Gateway Security and Authorization

A company is building a mobile travel application where users authenticate via a client interface and receive a JSON Web Token (JWT). The application's backend services are exposed through an Amazon API Gateway REST API. The developer needs to secure the API endpoints so that only authenticated users can access them, verifying the JWT signature on each request. Which of the following is the most operationally efficient method to implement this security requirement with the least development effort?

  1. Configure a Cognito User Pools authorizer on the API Gateway method to validate the incoming tokens automatically.Answer
  2. B
    Configure a Cognito Identity Pools authorizer on the API Gateway method to validate the incoming tokens automatically.
  3. C
    Create a custom Lambda authorizer that parses, validates, and verifies the incoming JSON Web Token signature on each request.
  4. D
    Implement custom token verification logic directly within the backend Lambda function using a Lambda Proxy integration.

Answer

Configure a Cognito User Pools authorizer on the API Gateway method to validate the incoming tokens automatically.
Using a Cognito User Pools authorizer is the most operationally efficient approach. It leverages API Gateway's built-in capability to automatically validate incoming JSON Web Tokens (JWTs) without requiring custom code or additional Lambda executions for validation, lowering development effort and ongoing maintenance.

Step-by-Step Solution

1
Identify the token type and authentication provider.
The application uses JSON Web Tokens (JWT) generated by a Cognito User Pool for user authentication.
Knowing the token format helps choose between native integrations and custom authorization logic.
2
Compare native integration versus custom code solutions.
API Gateway offers a built-in Cognito User Pools authorizer, whereas custom Lambda authorizers require writing token verification code.
Evaluating options based on developer effort and operational efficiency helps identify the best option with the least overhead.
3
Select the built-in Cognito User Pools authorizer.
API Gateway automatically verifies the JWT signature and expiration, allowing only valid requests to reach the backend.
This satisfies the requirement of validating tokens with minimal custom code and maximum operational efficiency.

Key Concept

Amazon API Gateway Cognito User Pools Authorizer
Estimated Time:1m 30s
Rate this question