An enterprise has a backend service running on Amazon EC2 that needs to securely communicate with a protected REST API hosted on Amazon API Gateway. There is no user interaction involved in this communication. The developer wants to implement a secure, scalable authentication and authorization mechanism using Amazon Cognito to protect the API. How should the developer configure Amazon Cognito and API Gateway to meet these requirements with the least operational overhead?
- AConfigure an Identity Pool to authenticate the backend service, retrieve temporary AWS credentials, and use these credentials to sign the requests using Signature Version 4 while using IAM authorization on the API Gateway.
- BCreate a User Pool with client credentials grant enabled, and configure a custom Lambda authorizer on the API Gateway to verify, decode, and parse the signature of the Cognito JSON Web Token (JWT).
- Create a User Pool and configure a resource server with custom scopes. Enable the client credentials flow for the service's app client, and use the built-in Cognito authorizer on the API Gateway to validate the incoming access token.Cevap
- DCreate a User Pool and an IAM role with a trust policy allowing API Gateway to assume it. Have the backend service exchange its user pool credentials for the IAM role using the AWS Security Token Service (STS) prior to each request.
Cevap
Create a User Pool and configure a resource server with custom scopes. Enable the client credentials flow for the service's app client, and use the built-in Cognito authorizer on the API Gateway to validate the incoming access token.
The correct option is the one that suggests creating a User Pool and configuring a resource server with custom scopes, enabling the client credentials flow, and utilizing the built-in Cognito authorizer on API Gateway. For machine-to-machine (M2M) communication without user intervention, the OAuth 2.0 client credentials grant is the industry standard. Amazon Cognito User Pools natively support this flow through resource servers. Additionally, API Gateway provides a built-in Cognito User Pool authorizer that automatically validates the signature and expiration of the access token, as well as checking custom scopes, minimizing custom code and operational overhead.
Adım Adım Çözüm
Anahtar Kavram
Machine-to-machine authentication using Cognito User Pools and API Gateway Cognito Authorizers
Tahmini Süre:1m 30s