Skip to content

Commit f9d6eef

Browse files
authored
feat(cognito): support email based MFA (#31816)
### Issue # (if applicable) Closes #31815. ### Reason for this change To use email based MFA. ### Description of changes Add email option to [MfaSecondFactor](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.MfaSecondFactor.html). ### Description of how you validated changes Add unit tests and integ test. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent e96b4ce commit f9d6eef

13 files changed

+782
-5
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-mfa-email.js.snapshot/cdk.out

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-mfa-email.js.snapshot/integ-user-email-mfa.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
{
2+
"Resources": {
3+
"myuserpoolsmsRole0E16FDD9": {
4+
"Type": "AWS::IAM::Role",
5+
"Properties": {
6+
"AssumeRolePolicyDocument": {
7+
"Statement": [
8+
{
9+
"Action": "sts:AssumeRole",
10+
"Condition": {
11+
"StringEquals": {
12+
"sts:ExternalId": "integuseremailmfamyuserpool8F31F20B"
13+
}
14+
},
15+
"Effect": "Allow",
16+
"Principal": {
17+
"Service": "cognito-idp.amazonaws.com"
18+
}
19+
}
20+
],
21+
"Version": "2012-10-17"
22+
},
23+
"Policies": [
24+
{
25+
"PolicyDocument": {
26+
"Statement": [
27+
{
28+
"Action": "sns:Publish",
29+
"Effect": "Allow",
30+
"Resource": "*"
31+
}
32+
],
33+
"Version": "2012-10-17"
34+
},
35+
"PolicyName": "sns-publish"
36+
}
37+
]
38+
}
39+
},
40+
"myuserpool01998219": {
41+
"Type": "AWS::Cognito::UserPool",
42+
"Properties": {
43+
"AccountRecoverySetting": {
44+
"RecoveryMechanisms": [
45+
{
46+
"Name": "verified_phone_number",
47+
"Priority": 1
48+
},
49+
{
50+
"Name": "verified_email",
51+
"Priority": 2
52+
}
53+
]
54+
},
55+
"AdminCreateUserConfig": {
56+
"AllowAdminCreateUserOnly": true
57+
},
58+
"EmailConfiguration": {
59+
"EmailSendingAccount": "DEVELOPER",
60+
"From": "\"[email protected]\" <noreply@*.example.com>",
61+
"ReplyToEmailAddress": "support@*.example.com",
62+
"SourceArn": {
63+
"Fn::Join": [
64+
"",
65+
[
66+
"arn:",
67+
{
68+
"Ref": "AWS::Partition"
69+
},
70+
":ses:us-east-1:",
71+
{
72+
"Ref": "AWS::AccountId"
73+
},
74+
":identity/*.example.com"
75+
]
76+
]
77+
}
78+
},
79+
"EmailVerificationMessage": "The verification code to your new account is {####}",
80+
"EmailVerificationSubject": "Verify your new account",
81+
"EnabledMfas": [
82+
"SMS_MFA",
83+
"EMAIL_OTP"
84+
],
85+
"MfaConfiguration": "ON",
86+
"SmsConfiguration": {
87+
"ExternalId": "integuseremailmfamyuserpool8F31F20B",
88+
"SnsCallerArn": {
89+
"Fn::GetAtt": [
90+
"myuserpoolsmsRole0E16FDD9",
91+
"Arn"
92+
]
93+
}
94+
},
95+
"SmsVerificationMessage": "The verification code to your new account is {####}",
96+
"UserPoolAddOns": {
97+
"AdvancedSecurityMode": "ENFORCED"
98+
},
99+
"UserPoolName": "MyUserPool",
100+
"VerificationMessageTemplate": {
101+
"DefaultEmailOption": "CONFIRM_WITH_CODE",
102+
"EmailMessage": "The verification code to your new account is {####}",
103+
"EmailSubject": "Verify your new account",
104+
"SmsMessage": "The verification code to your new account is {####}"
105+
}
106+
},
107+
"UpdateReplacePolicy": "Delete",
108+
"DeletionPolicy": "Delete"
109+
}
110+
},
111+
"Outputs": {
112+
"userpoolid": {
113+
"Value": {
114+
"Ref": "myuserpool01998219"
115+
}
116+
}
117+
},
118+
"Parameters": {
119+
"BootstrapVersion": {
120+
"Type": "AWS::SSM::Parameter::Value<String>",
121+
"Default": "/cdk-bootstrap/hnb659fds/version",
122+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
123+
}
124+
},
125+
"Rules": {
126+
"CheckBootstrapVersion": {
127+
"Assertions": [
128+
{
129+
"Assert": {
130+
"Fn::Not": [
131+
{
132+
"Fn::Contains": [
133+
[
134+
"1",
135+
"2",
136+
"3",
137+
"4",
138+
"5"
139+
],
140+
{
141+
"Ref": "BootstrapVersion"
142+
}
143+
]
144+
}
145+
]
146+
},
147+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
148+
}
149+
]
150+
}
151+
}
152+
}

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-mfa-email.js.snapshot/integ.json

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-mfa-email.js.snapshot/integuseremailmfatestDefaultTestDeployAssertD4C43B3C.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-mfa-email.js.snapshot/integuseremailmfatestDefaultTestDeployAssertD4C43B3C.template.json

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cognito/test/integ.user-pool-mfa-email.js.snapshot/manifest.json

+127
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)