A developer is implementing authorization for an Amazon API Gateway REST API. The API serves as the backend for a web application where users register and log in directly using Amazon Cognito. The developer needs to validate the JSON Web Tokens (JWT) sent in the HTTP authorization header for each request. The solution should minimize both custom development effort and operational overhead. Which of the following approaches should the developer choose to secure the API?
- Deploy a native Amazon Cognito authorizer on the API Gateway REST API resources to validate the incoming tokens.Cevap
- BWrite a Lambda token authorizer that downloads the JSON Web Key Set (JWKS), decodes the token, and performs signature verification.
- CUse an Amazon Cognito federated identity pool to exchange the token for temporary security credentials to sign requests with Signature Version 4.
- DSet up a Lambda proxy integration and handle token decryption and validation within the business logic of the backend Lambda function.
Cevap
Deploy a native Amazon Cognito authorizer on the API Gateway REST API resources to validate the incoming tokens.
Deploying a native Amazon Cognito authorizer is the correct approach. API Gateway provides built-in integration with Cognito User Pools. By configuring a Cognito authorizer, API Gateway automatically validates the signature and expiration of the JWT before forwarding the request to the integration backend. This requires zero custom code, minimizes developer effort, and lowers latency and costs.
Adım Adım Çözüm
Anahtar Kavram
Amazon API Gateway Cognito User Pools Authorizer
Tahmini Süre:1m 30s