A developer is building a corporate portal where employees must sign in using their existing SAML 2.0 Identity Provider (IdP) credentials. The portal's backend API, hosted on Amazon API Gateway, requires custom user claims such as department and employee ID to perform fine-grained authorization. Which configuration will meet these requirements with the least development effort?
- Configure the SAML 2.0 IdP as a federated identity provider in a Cognito User Pool, map the SAML assertions to the corresponding user pool attributes, and configure API Gateway to use a Cognito User Pool authorizer.Answer
- BConfigure the SAML 2.0 IdP in a Cognito Identity Pool, map the SAML assertions to IAM principal tags, and configure API Gateway to use IAM authorization for the backend API.
- CConfigure the SAML 2.0 IdP as a federated identity provider in a Cognito User Pool, map the SAML assertions to custom user pool attributes, and write a custom API Gateway Lambda authorizer to parse and validate the SAML token directly.
- DConfigure the SAML 2.0 IdP in a Cognito Identity Pool, map the SAML assertions to Cognito User Pool attributes using a Custom Message Lambda trigger, and configure API Gateway to use a Cognito User Pool authorizer.
Answer
Configure the SAML 2.0 IdP as a federated identity provider in a Cognito User Pool, map the SAML assertions to the corresponding user pool attributes, and configure API Gateway to use a Cognito User Pool authorizer.
Configuring the SAML 2.0 IdP within a Cognito User Pool and mapping its assertions to user pool attributes allows the identity directory to generate JWT ID/access tokens containing the custom claims. Using the native Cognito User Pool authorizer in API Gateway validates these tokens automatically, presenting the claims to the backend integration with minimal configuration and no custom code.
Step-by-Step Solution
Key Concept
Amazon Cognito User Pools support SAML 2.0 federation and direct attribute mapping, allowing standard API Gateway Cognito Authorizers to automatically validate tokens and pass mapped claims to backend integrations without custom Lambda code.