An enterprise web application requires federated authentication via an external SAML 2.0 Identity Provider (IdP). Once authenticated, users must be able to download files directly from an Amazon S3 bucket. Access must be restricted such that users can only download objects from an S3 prefix that matches their department name (e.g., `company-data/hr/*` for the 'hr' department). The department name is supplied as a custom SAML assertion claim named `department`.
Which configuration should the developer implement to meet these requirements with the least administrative and coding overhead?
- Configure an Amazon Cognito Identity Pool with the SAML IdP. Set up Attribute Mapping to map the SAML `department` claim to the principal tag `department`. In the IAM policy attached to the authenticated role, grant `s3:GetObject` permission for the resource `arn:aws:s3:::company-data/${aws:PrincipalTag/department}/*`.Cevap
- BConfigure an Amazon Cognito User Pool with the SAML IdP. Create a Post Authentication AWS Lambda trigger that checks the user's `department` attribute, generates temporary AWS credentials with a dynamic policy, and stores them in the User Pool's custom user attributes for the client to retrieve.
- CConfigure an Amazon API Gateway endpoint with a custom Lambda Authorizer. Send the SAML assertion to API Gateway, and have the Lambda Authorizer validate it, perform an AWS STS `AssumeRole` call to get temporary credentials for the specific department prefix, and return the credentials inside the authorizer's output context.
- DConfigure an Amazon Cognito Identity Pool with the SAML IdP. Create separate IAM roles for each department with corresponding S3 bucket policies. Use a custom Lambda function to update the Identity Pool's role mapping rules daily to map each user's email address to their specific department's IAM role.
Cevap
Configure an Amazon Cognito Identity Pool with the SAML IdP, map the SAML attribute to the principal tag, and reference the tag in the IAM policy using a policy variable.
The correct option maps the SAML assertion claim to a principal tag in the Cognito Identity Pool configuration. This allows the IAM role to use Attribute-Based Access Control (ABAC) and dynamic policy variables (`${aws:PrincipalTag/department}`) to restrict access to department-specific prefixes in S3 with a single IAM role, minimizing overhead.
Adım Adım Çözüm
Anahtar Kavram
Attribute-Based Access Control (ABAC) with Amazon Cognito Identity Pools and SAML federation
Tahmini Süre:2m 0s