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?
- Configure a Lambda authorizer to validate the JWT and return an IAM policy along with a context object containing the user identity details.Cevap
- BConfigure a built-in Amazon Cognito User Pool authorizer and map the external token claims to the backend using mapping templates.
- CUse a Lambda Proxy Integration and configure the backend Lambda function to extract, validate, and parse the JWT from the raw request event.
- DCreate 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
Anahtar Kavram
API Gateway Lambda Authorizers
Tahmini Süre:1m 30s