A developer is designing a secure mobile banking application. The application uses Amazon API Gateway for its backend REST APIs and stores user documents in an Amazon S3 bucket. The security requirements are:
1. Access to the API Gateway APIs must be restricted to authenticated users. The API Gateway must natively validate the users' JSON Web Tokens (JWTs) without invoking a custom function.
2. Users must be able to upload documents directly to their own folder within the S3 bucket using temporary AWS credentials, ensuring least-privilege access.
Which two configurations should the developer implement to meet these requirements?
- AConfigure an API Gateway Lambda Custom Authorizer to validate the JWT, then invoke AssumeRole against AWS STS to return temporary AWS credentials directly in the authorization context to S3.
- Configure a Cognito User Pool Authorizer on the API Gateway REST API to natively validate the JSON Web Tokens (JWTs) provided by the client application.Answer
- CConfigure a Cognito Identity Pool as the primary API Gateway Authorizer, and use the Identity Pool client credentials to authenticate REST API calls via Lambda Proxy integration.
- Associate the Cognito User Pool with a Cognito Identity Pool to exchange authenticated tokens for temporary AWS IAM credentials, and assign an IAM policy with resource-level permissions for S3 folder access.Answer
- ECreate a Cognito User Pool and write an IAM policy that allows the User Pool client credentials to authenticate S3 API calls using KMS envelope encryption.
Answer
To meet the requirements, the developer should configure a Cognito User Pool Authorizer on the API Gateway REST API to natively validate user tokens, and associate the Cognito User Pool with a Cognito Identity Pool to issue temporary AWS IAM credentials with policies that grant restricted folder access to the S3 bucket.
The correct configurations involve using a Cognito User Pool Authorizer to validate JWT tokens natively at the API Gateway level, and utilizing a Cognito Identity Pool in conjunction with the User Pool to provide authenticated users with temporary AWS IAM credentials. This enables secure, direct document uploads to specific S3 folders using IAM policies containing user identity variables.
Step-by-Step Solution
Key Concept
Combining Cognito User Pools for native API Gateway authorization and Cognito Identity Pools for exchanging authentication tokens for temporary AWS credentials to access S3 directly under least privilege.
Estimated Time:2m 0s