Soru

Zorluk: OrtaAmazon Cognito Authentication and Authorization

A developer is building a serverless web application where users sign in using their email and password. Once authenticated, the application must allow users to upload files to a private Amazon S3 bucket and make requests to a backend API hosted on Amazon API Gateway. The developer wants to leverage Amazon Cognito for authentication and authorization. Which TWO configuration steps should the developer perform to meet these requirements with the least operational overhead?

  1. Configure an Amazon Cognito User Pool to handle user registration and sign-in, and use a Cognito authorizer in Amazon API Gateway to authenticate API requests.Cevap
  2. Configure an Amazon Cognito Identity Pool linked to the User Pool, and map Cognito user groups to IAM roles that grant the required Amazon S3 permissions.Cevap
  3. C
    Use the Amazon Cognito User Pool directly to issue temporary AWS credentials for the web application to perform the Amazon S3 upload.
  4. D
    Create a custom API Gateway Lambda authorizer to decode, verify, and validate the JSON Web Tokens (JWTs) sent from the client application.
  5. E
    Configure an Amazon Cognito Identity Pool to store user profiles, manage email verification, and enforce multi-factor authentication (MFA).

Cevap

Configure an Amazon Cognito User Pool to handle user registration and sign-in, use a Cognito authorizer in Amazon API Gateway, and configure an Amazon Cognito Identity Pool linked to the User Pool to map user groups to IAM roles for S3 access.
The correct solution involves using a Cognito User Pool to register and authenticate users, generating JWTs. A Cognito Identity Pool is then linked to the User Pool to exchange these JWTs for temporary AWS IAM credentials, which are mapped to specific roles allowing S3 upload access. Finally, the native Cognito authorizer in API Gateway is configured to validate the User Pool's tokens directly, minimizing operational overhead.

Adım Adım Çözüm

1
Set up authentication directory.
Created an Amazon Cognito User Pool to manage user sign-up, sign-in, and generate JWT tokens.
User Pools act as the identity provider for user credentials and session management.
2
Establish S3 authorization.
Created an Amazon Cognito Identity Pool, integrated it with the User Pool, and mapped user groups to IAM roles with S3 permissions.
Identity Pools are necessary to vend temporary AWS credentials required for direct S3 API interactions.
3
Configure API Gateway protection.
Configured a Cognito authorizer on the API Gateway REST API endpoints.
Using the built-in Cognito authorizer allows API Gateway to validate User Pool tokens natively without needing custom Lambda code.

Anahtar Kavram

Amazon Cognito Authentication and Authorization Integration
Bu soruyu puanla