A digital media streaming service uses Amazon API Gateway to expose a REST API that retrieves subscriber profiles. The backend integration uses an AWS Lambda function with a proxy integration. The company uses a custom external identity provider that issues JSON Web Tokens (JWTs) to authenticated users. The developer must secure the API Gateway endpoints to ensure that only users with an active subscription (indicated by a claim named 'subscriptionStatus' with a value of 'active' inside the JWT payload) can access the API. The solution must minimize costs by preventing unauthorized requests from invoking the backend Lambda function, and must cache the authorization decision for 5 minutes. Which security configuration will meet these requirements?
- Configure a Lambda token authorizer in API Gateway. In the authorizer's Lambda function, validate the JWT signature, extract the 'subscriptionStatus' claim, and return an IAM policy that allows access if the status is active or denies access otherwise. Enable authorizer caching and set the identity source to the header containing the JWT.Answer
- BConfigure an Amazon Cognito User Pool Authorizer in API Gateway. In the API Gateway method settings, set the authorization to the Cognito User Pool, and configure a Gateway Response to check the 'subscriptionStatus' claim value. Enable API Gateway execution caching for 5 minutes with the token header as the cache key.
- CConfigure an Amazon Cognito Identity Pool to federate with the external identity provider. Configure the API Gateway method to use IAM Authorization. Write a custom IAM policy that grants invoke permissions to API Gateway only if the 'subscriptionStatus' tag is present in the request credentials, and assign it to the Cognito authenticated role.
- DSet the API Gateway authorization to NONE to bypass authorizers. In the backend Lambda function, validate the JWT signature, inspect the 'subscriptionStatus' claim, and return a 403 Forbidden response if the status is not active. Enable API Gateway method execution caching for 5 minutes with the authorization header as the cache key.