Soru

Zorluk: OrtaAPI Development and Integration with Amazon API Gateway

A developer is building a REST API in Amazon API Gateway that integrates with a backend AWS Lambda function. The API must secure its endpoints by validating custom JSON Web Tokens (JWTs) issued by an external, third-party identity provider. If the token is valid, the API must pass the verified user identity details to the backend Lambda function; otherwise, it must block the request before it reaches the backend. Which API Gateway configuration should the developer use to satisfy these requirements?

  1. Configure a Lambda authorizer to validate the JWT and return an IAM policy along with a context object containing the user identity details.Cevap
  2. B
    Configure a built-in Amazon Cognito User Pool authorizer and map the external token claims to the backend using mapping templates.
  3. C
    Use a Lambda Proxy Integration and configure the backend Lambda function to extract, validate, and parse the JWT from the raw request event.
  4. D
    Create an Amazon Cognito Identity Pool to authenticate users and enable IAM authorization on the API Gateway method.

Cevap

Configure a Lambda authorizer to validate the JWT and return an IAM policy along with a context object containing the user identity details.
The correct option is to use a Lambda authorizer. A Lambda authorizer intercepts incoming requests, executes custom validation code for third-party tokens, and returns an IAM policy. It can also return a custom context map containing verified user details that API Gateway passes directly to the backend integration.

Adım Adım Çözüm

1
Determine validation requirements for third-party identity providers
Identify that built-in Cognito User Pool authorizers cannot be used because the token is not issued by Cognito.
Cognito User Pool authorizers only accept Cognito-issued tokens.
2
Select the correct authorizer type to execute custom validation logic
Choose a Lambda authorizer (custom authorizer) to run the code necessary to validate the third-party JWT signature and claims.
Lambda authorizers allow developers to implement custom authentication and validation logic.
3
Configure the authorizer response payload to pass context downstream
Ensure the Lambda authorizer returns an IAM policy along with a context map containing key-value pairs representing the user identity details.
API Gateway automatically forwards key-value pairs in the context map to the backend integration, allowing the backend Lambda function to access the user context.

Anahtar Kavram

API Gateway Lambda Authorizers
Tahmini Süre:1m 30s
Bu soruyu puanla