Skip to content

Commit 024e506

Browse files
Jordan-Nelsontyllark
authored andcommitted
chore: migrate sms only MFA infra to Gen 2 (aws-amplify#5291)
* chore: add new auth backend * chore: add auth extension * chore: add license headers * chore: add mfa to env * chore: add trigger to enable MFA * chore: add infra for sms required * chore: refactor tests for gen 2 backends * chore: add backends to deploy script * chore: package-lock for mfa-required-sms * chore: remove bundling of @aws-crypto/client-node * chore: fix formatting
1 parent b5ea96d commit 024e506

28 files changed

+423
-150
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# amplify
2+
node_modules
3+
.amplify
4+
amplify_outputs*
5+
amplifyconfiguration*
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import { defineAuth } from "@aws-amplify/backend";
5+
6+
export const auth = defineAuth({
7+
loginWith: {
8+
email: true,
9+
},
10+
multifactor: {
11+
mode: "OPTIONAL",
12+
sms: true,
13+
},
14+
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import { defineBackend } from "@aws-amplify/backend";
5+
import { addAuthUserExtensions } from "infra-common";
6+
import { auth } from "./auth/resource";
7+
8+
const backend = defineBackend({
9+
auth,
10+
});
11+
12+
const resources = backend.auth.resources;
13+
const { userPool, cfnResources } = resources;
14+
const { stack } = userPool;
15+
const { cfnUserPool } = cfnResources;
16+
17+
// Adds infra for creating/deleting users via App Sync and fetching confirmation
18+
// and MFA codes from App Sync.
19+
const customOutputs = addAuthUserExtensions({
20+
name: "mfa-optional-sms",
21+
stack,
22+
userPool,
23+
cfnUserPool,
24+
});
25+
backend.addOutput(customOutputs);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "module"
3+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2022",
4+
"module": "es2022",
5+
"moduleResolution": "bundler",
6+
"resolveJsonModule": true,
7+
"esModuleInterop": true,
8+
"forceConsistentCasingInFileNames": true,
9+
"strict": true,
10+
"skipLibCheck": true,
11+
"paths": {
12+
"$amplify/*": [
13+
"../.amplify/generated/*"
14+
]
15+
}
16+
}
17+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "mfa-optional-sms",
3+
"version": "1.0.0",
4+
"main": "index.js"
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# amplify
2+
node_modules
3+
.amplify
4+
amplify_outputs*
5+
amplifyconfiguration*
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import { defineAuth } from "@aws-amplify/backend";
5+
6+
export const auth = defineAuth({
7+
loginWith: {
8+
email: true,
9+
},
10+
multifactor: {
11+
mode: "REQUIRED",
12+
sms: true,
13+
},
14+
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import { defineBackend } from "@aws-amplify/backend";
5+
import { addAuthUserExtensions } from "infra-common";
6+
import { auth } from "./auth/resource";
7+
8+
const backend = defineBackend({
9+
auth,
10+
});
11+
12+
const resources = backend.auth.resources;
13+
const { userPool, cfnResources } = resources;
14+
const { stack } = userPool;
15+
const { cfnUserPool } = cfnResources;
16+
17+
// Adds infra for creating/deleting users via App Sync and fetching confirmation
18+
// and MFA codes from App Sync.
19+
const customOutputs = addAuthUserExtensions({
20+
name: "mfa-required-sms",
21+
stack,
22+
userPool,
23+
cfnUserPool,
24+
});
25+
backend.addOutput(customOutputs);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "module"
3+
}

0 commit comments

Comments
 (0)