Skip to content

Commit

Permalink
feat(auth, authenticator): Add support for Email OTP MFA (aws-amplify…
Browse files Browse the repository at this point in the history
…#5449) (aws-amplify#5472)

* feat: Added support for Email OTP MFA
  • Loading branch information
khatruong2009 authored and tyllark committed Oct 31, 2024
1 parent 123962f commit 3629536
Show file tree
Hide file tree
Showing 265 changed files with 5,359 additions and 344 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@

## Generated SDK files
packages/**/lib/src/sdk/src/** linguist-generated
packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_exception.dart linguist-generated

## Generated Swift Plugins
packages/amplify_datastore/ios/internal/** linguist-generated
Expand Down
5 changes: 5 additions & 0 deletions infra-gen2/backends/auth/mfa-optional-email-sms/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# amplify
node_modules
.amplify
amplify_outputs*
amplifyconfiguration*
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { defineAuth } from "@aws-amplify/backend";

export const auth = defineAuth({
name: "mfa-optional-email-sms",
loginWith: {
email: true,
},

// TODO(khatruong2009): Uncomment the following line when the feature is ready.
// multifactor: {
// mode: "OPTIONAL",
// email: true,
// sms: true,
// },
});
25 changes: 25 additions & 0 deletions infra-gen2/backends/auth/mfa-optional-email-sms/amplify/backend.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { defineBackend } from "@aws-amplify/backend";
import { addAuthUserExtensions } from "infra-common";
import { auth } from "./auth/resource";

const backend = defineBackend({
auth,
});

const resources = backend.auth.resources;
const { userPool, cfnResources } = resources;
const { stack } = userPool;
const { cfnUserPool } = cfnResources;

// Adds infra for creating/deleting users via App Sync and fetching confirmation
// and MFA codes from App Sync.
const customOutputs = addAuthUserExtensions({
name: "mfa-optional-email-sms",
stack,
userPool,
cfnUserPool,
});
backend.addOutput(customOutputs);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "es2022",
"module": "es2022",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"paths": {
"$amplify/*": [
"../.amplify/generated/*"
]
}
}
}
5 changes: 5 additions & 0 deletions infra-gen2/backends/auth/mfa-optional-email-sms/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "mfa-optional-email-sms",
"version": "1.0.0",
"main": "index.js"
}
5 changes: 5 additions & 0 deletions infra-gen2/backends/auth/mfa-optional-email-totp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# amplify
node_modules
.amplify
amplify_outputs*
amplifyconfiguration*
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { defineAuth } from "@aws-amplify/backend";

export const auth = defineAuth({
name: "mfa-optional-email-totp",
loginWith: {
email: true,
},

// TODO(khatruong2009): Uncomment the following line when the feature is ready.
// multifactor: {
// mode: "OPTIONAL",
// email: true,
// totp: true,
// },
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { defineBackend } from "@aws-amplify/backend";
import { addAuthUserExtensions } from "infra-common";
import { auth } from "./auth/resource";

const backend = defineBackend({
auth,
});

const resources = backend.auth.resources;
const { userPool, cfnResources } = resources;
const { stack } = userPool;
const { cfnUserPool } = cfnResources;

// Adds infra for creating/deleting users via App Sync and fetching confirmation
// and MFA codes from App Sync.
const customOutputs = addAuthUserExtensions({
name: "mfa-optional-email-totp",
stack,
userPool,
cfnUserPool,
});
backend.addOutput(customOutputs);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "es2022",
"module": "es2022",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"paths": {
"$amplify/*": [
"../.amplify/generated/*"
]
}
}
}
5 changes: 5 additions & 0 deletions infra-gen2/backends/auth/mfa-optional-email-totp/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "mfa-optional-email-totp",
"version": "1.0.0",
"main": "index.js"
}
5 changes: 5 additions & 0 deletions infra-gen2/backends/auth/mfa-optional-email/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# amplify
node_modules
.amplify
amplify_outputs*
amplifyconfiguration*
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { defineAuth } from "@aws-amplify/backend";

export const auth = defineAuth({
name: "mfa-optional-email",
loginWith: {
email: true,
},

// TODO(khatruong2009): Uncomment the following line when the feature is ready.
// multifactor: {
// mode: "OPTIONAL",
// email: true,
// },
});
25 changes: 25 additions & 0 deletions infra-gen2/backends/auth/mfa-optional-email/amplify/backend.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { defineBackend } from "@aws-amplify/backend";
import { addAuthUserExtensions } from "infra-common";
import { auth } from "./auth/resource";

const backend = defineBackend({
auth,
});

const resources = backend.auth.resources;
const { userPool, cfnResources } = resources;
const { stack } = userPool;
const { cfnUserPool } = cfnResources;

// Adds infra for creating/deleting users via App Sync and fetching confirmation
// and MFA codes from App Sync.
const customOutputs = addAuthUserExtensions({
name: "mfa-optional-email",
stack,
userPool,
cfnUserPool,
});
backend.addOutput(customOutputs);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
17 changes: 17 additions & 0 deletions infra-gen2/backends/auth/mfa-optional-email/amplify/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "es2022",
"module": "es2022",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"paths": {
"$amplify/*": [
"../.amplify/generated/*"
]
}
}
}
5 changes: 5 additions & 0 deletions infra-gen2/backends/auth/mfa-optional-email/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "mfa-optional-email",
"version": "1.0.0",
"main": "index.js"
}
5 changes: 5 additions & 0 deletions infra-gen2/backends/auth/mfa-required-email-sms/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# amplify
node_modules
.amplify
amplify_outputs*
amplifyconfiguration*
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { defineAuth } from "@aws-amplify/backend";

export const auth = defineAuth({
name: "mfa-required-email-sms",
loginWith: {
email: true,
},
// TODO(khatruong2009): Uncomment the following line when the feature is ready.
// multifactor: {
// mode: "REQUIRED",
// email: true,
// sms: true,
// },
});
25 changes: 25 additions & 0 deletions infra-gen2/backends/auth/mfa-required-email-sms/amplify/backend.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { defineBackend } from "@aws-amplify/backend";
import { addAuthUserExtensions } from "infra-common";
import { auth } from "./auth/resource";

const backend = defineBackend({
auth,
});

const resources = backend.auth.resources;
const { userPool, cfnResources } = resources;
const { stack } = userPool;
const { cfnUserPool } = cfnResources;

// Adds infra for creating/deleting users via App Sync and fetching confirmation
// and MFA codes from App Sync.
const customOutputs = addAuthUserExtensions({
name: "mfa-required-email-sms",
stack,
userPool,
cfnUserPool,
});
backend.addOutput(customOutputs);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "es2022",
"module": "es2022",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"paths": {
"$amplify/*": [
"../.amplify/generated/*"
]
}
}
}
5 changes: 5 additions & 0 deletions infra-gen2/backends/auth/mfa-required-email-sms/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "mfa-required-email-sms",
"version": "1.0.0",
"main": "index.js"
}
5 changes: 5 additions & 0 deletions infra-gen2/backends/auth/mfa-required-email-totp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# amplify
node_modules
.amplify
amplify_outputs*
amplifyconfiguration*
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { defineAuth } from "@aws-amplify/backend";

export const auth = defineAuth({
name: "mfa-required-email-totp",
loginWith: {
email: true,
},
// TODO(khatruong2009): Uncomment the following line when the feature is ready.
// multifactor: {
// mode: "REQUIRED",
// email: true,
// totp: true,
// },
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { defineBackend } from "@aws-amplify/backend";
import { addAuthUserExtensions } from "infra-common";
import { auth } from "./auth/resource";

const backend = defineBackend({
auth,
});

const resources = backend.auth.resources;
const { userPool, cfnResources } = resources;
const { stack } = userPool;
const { cfnUserPool } = cfnResources;

// Adds infra for creating/deleting users via App Sync and fetching confirmation
// and MFA codes from App Sync.
const customOutputs = addAuthUserExtensions({
name: "mfa-required-email-totp",
stack,
userPool,
cfnUserPool,
});
backend.addOutput(customOutputs);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
Loading

0 comments on commit 3629536

Please sign in to comment.