-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add new backend for username only login
- Loading branch information
1 parent
d85e665
commit 453a175
Showing
8 changed files
with
126 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# amplify | ||
node_modules | ||
.amplify | ||
amplify_outputs* | ||
amplifyconfiguration* |
19 changes: 19 additions & 0 deletions
19
infra-gen2/backends/auth/username-login-mfa/amplify/auth/resource.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// 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", | ||
loginWith: { | ||
phone: true, | ||
}, | ||
// TODO(khatruong2009): Uncomment the following line when the feature is ready. | ||
// multifactor: { | ||
// mode: "REQUIRED", | ||
// email: true, | ||
// sms: true, | ||
// totp: true, | ||
// }, | ||
accountRecovery: "PHONE_WITHOUT_MFA_AND_EMAIL", | ||
}); |
40 changes: 40 additions & 0 deletions
40
infra-gen2/backends/auth/username-login-mfa/amplify/backend.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// 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: "username-login-mfa", | ||
stack, | ||
userPool, | ||
cfnUserPool, | ||
}); | ||
backend.addOutput(customOutputs); | ||
|
||
cfnUserPool.schema = undefined; | ||
cfnUserPool.usernameAttributes = []; | ||
cfnUserPool.emailConfiguration = { | ||
emailSendingAccount: "DEVELOPER", | ||
from: "ktruon@amazon.com", | ||
sourceArn: `arn:aws:ses:${stack.region}:${stack.account}:identity/ktruon@amazon.com`, | ||
}; | ||
cfnUserPool.adminCreateUserConfig = { | ||
allowAdminCreateUserOnly: true, | ||
}; | ||
cfnUserPool.autoVerifiedAttributes = []; | ||
cfnUserPool.userAttributeUpdateSettings = { | ||
attributesRequireVerificationBeforeUpdate: [], | ||
}; |
3 changes: 3 additions & 0 deletions
3
infra-gen2/backends/auth/username-login-mfa/amplify/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "module" | ||
} |
17 changes: 17 additions & 0 deletions
17
infra-gen2/backends/auth/username-login-mfa/amplify/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/*" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "username-login-mfa", | ||
"version": "1.0.0", | ||
"main": "index.js" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters