A developer is building a web dashboard that allows corporate employees to sign in using their existing third-party SAML Identity Provider (IdP). The application must access a secure REST API hosted on Amazon API Gateway. The developer wants to validate the user's session at the API Gateway layer using a built-in integration and extract the user's profile claims in the backend AWS Lambda function without writing custom token validation code.
Which configuration strategy should the developer implement to meet these requirements with the least development effort?
- AConfigure an Amazon Cognito Identity Pool federated with the SAML IdP. Use API Gateway IAM authorization, sign the API requests using the temporary AWS credentials, and decode the credentials in the Lambda function to extract user claims.
- BConfigure an Amazon Cognito User Pool federated with the SAML IdP. Create an API Gateway Lambda Authorizer that intercepts the SAML response, decodes the token, validates the signature, and injects the claims into the context.
- Configure an Amazon Cognito User Pool federated with the SAML IdP. Create a Cognito User Pool Authorizer in API Gateway and pass the Cognito ID token in the request header to access the API.Answer
- DConfigure an Amazon Cognito Identity Pool federated with the SAML IdP. Define an IAM role with a trust policy allowing public access, associate it with the API Gateway resource, and extract the SAML assertion directly from the API gateway context mapping.
Answer
Configure an Amazon Cognito User Pool federated with the SAML IdP. Create a Cognito User Pool Authorizer in API Gateway and pass the Cognito ID token in the request header to access the API.
Using Amazon Cognito User Pools federated with a SAML Identity Provider allows user directory and authentication federation. API Gateway's built-in Cognito User Pool Authorizer handles token validation natively, passing claims directly to the integration backend (Lambda) in the request context under authorizer claims. This eliminates the need for writing custom token validation code or signing API requests with AWS Signature Version 4.
Step-by-Step Solution
Key Concept
Built-in integration between API Gateway and Cognito User Pools for user authentication and claims propagation.
Estimated Time:1m 30s