A company is building a machine-to-machine (M2M) integration that allows an on-premises backend service to programmatically upload raw telemetry data to a private Amazon API Gateway endpoint. The developer needs to secure the API Gateway endpoint using Amazon Cognito. The backend service must authenticate using its credentials, obtain an access token, and use this token to authorize its API requests.
Which solution meets these requirements with the least operational overhead?
- Configure an Amazon Cognito User Pool with a resource server and a user pool client configured with the client credentials grant. In Amazon API Gateway, configure a Cognito User Pool authorizer and set the OAuth scopes on the API method.Cevap
- BConfigure an Amazon Cognito Identity Pool to federate the on-premises backend service. Use the developer-authenticated identities feature to generate temporary AWS credentials, and configure IAM authorization on the API Gateway endpoint.
- CConfigure an Amazon Cognito User Pool with a resource server and a user pool client configured with the client credentials grant. In Amazon API Gateway, write a custom Lambda authorizer to decode, verify, and validate the signature of the Cognito JWT access token.
- DConfigure an Amazon Cognito User Pool and create a user account for the on-premises service. Use the USER_PASSWORD_AUTH authentication flow to retrieve an ID token, and use an API Gateway Cognito User Pool authorizer to secure the method.
Cevap
Configure an Amazon Cognito User Pool with a resource server and a user pool client configured with the client credentials grant. In Amazon API Gateway, configure a Cognito User Pool authorizer and set the OAuth scopes on the API method.
The correct solution uses an Amazon Cognito User Pool with the client credentials grant to support machine-to-machine authentication. By defining a resource server with custom scopes, the backend service can retrieve a JWT access token. Securing the API Gateway is natively achieved by configuring a built-in Cognito User Pool authorizer and applying the custom OAuth scopes to the API method, which eliminates the need to write custom Lambda code or manage complex developer-authenticated identity flows.
Adım Adım Çözüm
Anahtar Kavram
Using Amazon Cognito User Pools for OAuth 2.0 client credentials grant and securing API Gateway with a built-in Cognito authorizer.