A logistics company is developing a cargo tracking application. The mobile client authenticates users via an Amazon Cognito User Pool. The client application needs to invoke a REST API hosted on Amazon API Gateway to fetch real-time tracking data. The developer wants to restrict access to this API endpoint to ensure that only users authenticated by the user pool can access it. Which approach should the developer use to meet these requirements with the lowest latency and minimal operational overhead?
- Configure an Amazon Cognito User Pool authorizer on the API Gateway method, and specify the client's identity or access token in the authorization header.Cevap
- BConfigure an Amazon Cognito Identity Pool authorizer on the API Gateway method, and specify the identity pool ID in the HTTP headers of the request.
- CCreate a custom AWS Lambda authorizer that validates the token signature using the Cognito User Pool public keys and generates an IAM policy for the request.
- DConfigure a Lambda proxy integration on the API Gateway method to pass the raw request to the backend function, then validate the token within the function's application code.
Cevap
Configure an Amazon Cognito User Pool authorizer on the API Gateway method, and specify the client's identity or access token in the authorization header.
Integrating Amazon API Gateway with an Amazon Cognito User Pool using a built-in Cognito User Pool authorizer allows API Gateway to natively validate the JSON Web Tokens (JWTs) sent by the client. This approach does not require writing or maintaining custom code, runs with minimal latency, and incurs no additional cost or execution time associated with Lambda custom authorizers.
Adım Adım Çözüm
Anahtar Kavram
Amazon API Gateway Cognito User Pool Authorizer
Tahmini Süre:1m 30s