A developer is designing a web application dashboard for a smart home IoT system. The application needs to allow users to sign in using their email and password or their social identity provider. Once authenticated, the web application must securely download and upload user-specific configuration files directly from an Amazon S3 bucket. Additionally, the application must invoke backend REST API endpoints hosted on Amazon API Gateway, which should only be accessible to authenticated users.
Which Cognito configuration should the developer choose to satisfy these requirements with the least operational overhead?
- AConfigure a Cognito Identity Pool to manage user registration, local password policies, and social provider integration. Secure the API Gateway REST API using an API Gateway Cognito Authorizer with the Identity Pool token, and access the S3 bucket using the same token.
- BConfigure a Cognito User Pool for user authentication and federation. Configure an API Gateway Custom Lambda Authorizer that calls the Cognito Identity Pool credentials exchange API for every request, and use the returned IAM credentials to authorize the user.
- Configure a Cognito User Pool to handle registration, login, and social identity provider federation. Secure the API Gateway REST API with a Cognito Authorizer using the User Pool ID token. Configure a Cognito Identity Pool with the User Pool as an identity provider to obtain temporary AWS credentials for S3 access.Answer
- DConfigure a Cognito User Pool to authenticate users. Store static IAM access keys and secret keys in the User Pool's custom user attributes, retrieve these attributes upon login, and use them to sign requests to API Gateway and S3.
Answer
Configure a Cognito User Pool to handle registration, login, and social identity provider federation. Secure the API Gateway REST API with a Cognito Authorizer using the User Pool ID token. Configure a Cognito Identity Pool with the User Pool as an identity provider to obtain temporary AWS credentials for S3 access.
The correct approach uses an Amazon Cognito User Pool to manage authentication (handling registration, local credentials, and social provider federation) and uses the resulting JSON Web Token (JWT) ID token to authorize API requests via the built-in API Gateway Cognito Authorizer. To access AWS resources like Amazon S3, a Cognito Identity Pool is required to exchange the User Pool tokens for temporary AWS IAM credentials.
Step-by-Step Solution
Key Concept
Distinction between Cognito User Pools (authentication and user directory) and Cognito Identity Pools (authorization and temporary AWS credentials exchange), as well as integrating User Pools with API Gateway Cognito Authorizers.
Estimated Time:1m 30s