Question

Difficulty: EasyAmazon Cognito Authentication and Authorization

A developer is building a serverless backend where users must register and sign in to access private API Gateway endpoints. The developer wants to use built-in AWS features to authenticate users and control access to the APIs with minimal custom code.

Which TWO Amazon Cognito features or configurations should the developer implement to meet these requirements? (Select TWO.)

  1. An Amazon Cognito User Pool to manage user registration, sign-in, and token generation.Answer
  2. An Amazon Cognito Authorizer in API Gateway to validate the JSON Web Tokens (JWTs) returned after user authentication.Answer
  3. C
    An Amazon Cognito Identity Pool to exchange user credentials for temporary AWS IAM credentials to access the API Gateway endpoints.
  4. D
    A custom Lambda Authorizer in API Gateway to manually parse and validate the tokens issued by Amazon Cognito.
  5. E
    An Amazon Cognito User Pool configured to attach AWS IAM policies directly to user profiles for API Gateway access.

Answer

Implementing an Amazon Cognito User Pool and configuring an Amazon Cognito Authorizer in API Gateway
To authenticate users and authorize API Gateway requests with minimal overhead, a developer should use an Amazon Cognito User Pool to handle user directory services (registration and sign-in) and token issuance, and pair it with an API Gateway Cognito Authorizer to validate those tokens at the API entry point.

Step-by-Step Solution

1
Set up user authentication and directory
Create an Amazon Cognito User Pool to serve as the user directory and handle registration, sign-in, and the issuance of JWT tokens.
This establishes the identity store and authentication mechanism for the application.
2
Configure API Gateway authorization
Configure an Amazon Cognito Authorizer on the API Gateway resource and point it to the Cognito User Pool.
This enables API Gateway to automatically intercept incoming requests, extract the JWT token from the Authorization header, and validate it against the User Pool.

Key Concept

Amazon Cognito User Pools provide authentication and issue tokens, while API Gateway Cognito Authorizers provide built-in token validation for authorization.
Rate this question