From bcb889ff00d4b09edbbab9908f233a4f850d9289 Mon Sep 17 00:00:00 2001 From: lazpavel <85319655+lazpavel@users.noreply.github.com> Date: Thu, 8 Jul 2021 14:19:26 -0400 Subject: [PATCH 01/15] Add .circleci/config.yml From f319345b13e5502420ba9eed8ae85cb731bc3297 Mon Sep 17 00:00:00 2001 From: Pavel Lazar Date: Mon, 26 Jul 2021 16:54:55 -0400 Subject: [PATCH 02/15] fix(amplify-category-auth): add auth user selections to aws-exports/amplifyconfiguration files --- .../utils/amplify-meta-updaters.ts | 72 ++++++++++++++++++- .../lib/frontend-config-creator.js | 2 + .../lib/frontend-config-creator.js | 2 + .../lib/frontend-config-creator.js | 2 + .../lib/frontend-config-creator.js | 25 +++++++ 5 files changed, 102 insertions(+), 1 deletion(-) diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts index a60adde2c5c..099b42a2394 100644 --- a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts @@ -16,7 +16,7 @@ export const getPostAddAuthMetaUpdater = (context: any, resultMetadata: { servic providerPlugin: resultMetadata.providerName, }; const parametersJSONPath = path.join(context.amplify.pathManager.getBackendDirPath(), 'auth', resourceName, 'parameters.json'); - const authParameters = JSONUtilities.readJson<{ dependsOn: any[]; triggers: string; identityPoolName: string }>(parametersJSONPath)!; + const authParameters = JSONUtilities.readJson<$TSAny>(parametersJSONPath)!; if (authParameters.dependsOn) { options.dependsOn = authParameters.dependsOn; @@ -36,6 +36,7 @@ export const getPostAddAuthMetaUpdater = (context: any, resultMetadata: { servic } options.customAuth = customAuthConfigured; + options.frontEndConfig = getFrontEndConfig(authParameters); context.amplify.updateamplifyMetaAfterResourceAdd('auth', resourceName, options); @@ -79,6 +80,7 @@ export const getPostUpdateAuthMetaUpdater = (context: any) => async (resourceNam triggers.VerifyAuthChallengeResponse.length > 0; } context.amplify.updateamplifyMetaAfterResourceUpdate('auth', resourceName, 'customAuth', customAuthConfigured); + context.amplify.updateamplifyMetaAfterResourceUpdate('auth', resourceName, 'frontEndConfig', getFrontEndConfig(authParameters)); // Update Identity Pool dependency attributes on userpool groups const allResources = context.amplify.getProjectMeta(); @@ -100,3 +102,71 @@ export const getPostUpdateAuthMetaUpdater = (context: any) => async (resourceNam } return resourceName; }; + +function getFrontEndConfig(authParameters: any) { + const frontEndConfig: any = {}; + + let loginMechanism: string[] = []; + + if (authParameters.aliasAttributes) { + let aliasAttributes = authParameters.aliasAttributes.map((att: string) => att.toUpperCase()); + loginMechanism = [...aliasAttributes]; + } + + if (authParameters.authProviders) { + if (authParameters.authProviders.includes('accounts.google.com')) { + loginMechanism.push('GOOGLE'); + } + if (authParameters.authProviders.includes('graph.facebook.com')) { + loginMechanism.push('FACEBOOK'); + } + if (authParameters.authProviders.includes('www.amazon.com')) { + loginMechanism.push('AMAZON'); + } + if (authParameters.authProviders.includes('appleid.apple.com')) { + loginMechanism.push('APPLE'); + } + } + + if (loginMechanism.length) { + frontEndConfig.loginMechanism = loginMechanism; + } + + if (authParameters.requiredAttributes) { + let requiredAttributes = authParameters.requiredAttributes.map((att: string) => att.toUpperCase()); + frontEndConfig.signupAttributes = [...requiredAttributes]; + } + + if (authParameters.mfaConfiguration) { + frontEndConfig.mfaConfiguration = authParameters.mfaConfiguration; + } + + if (authParameters.mfaTypes) { + frontEndConfig.mfaTypes = []; + + if (authParameters.mfaTypes.includes('SMS Text Message')) { + frontEndConfig.mfaTypes.push('SMS'); + } + + if (authParameters.mfaTypes.includes('TOTP')) { + frontEndConfig.mfaTypes.push('TOTP'); + } + } + + if (authParameters.passwordPolicyMinLength || authParameters.passwordPolicyCharacters) { + let passwordProtectionSettings: any = {}; + + if (authParameters.passwordPolicyMinLength) { + passwordProtectionSettings.passwordPolicyMinLength = authParameters.passwordPolicyMinLength; + } + + if (authParameters.passwordPolicyCharacters) { + let passwordPolicyCharacters = authParameters.passwordPolicyCharacters.map((i: string) => i.replace(/ /g, '_').toUpperCase()); + passwordProtectionSettings.passwordPolicyCharacters = passwordPolicyCharacters; + } + + frontEndConfig.passwordProtectionSettings = passwordProtectionSettings; + } + + return frontEndConfig; +} diff --git a/packages/amplify-frontend-android/lib/frontend-config-creator.js b/packages/amplify-frontend-android/lib/frontend-config-creator.js index 68ebccdf515..00f398c5cd2 100644 --- a/packages/amplify-frontend-android/lib/frontend-config-creator.js +++ b/packages/amplify-frontend-android/lib/frontend-config-creator.js @@ -264,6 +264,8 @@ function getCognitoConfig(cognitoResources, projectRegion) { }; } + Object.assign(cognitoConfig, cognitoResource.frontEndConfig); + return cognitoConfig; } diff --git a/packages/amplify-frontend-flutter/lib/frontend-config-creator.js b/packages/amplify-frontend-flutter/lib/frontend-config-creator.js index 6f2a4058c44..331eab6348f 100644 --- a/packages/amplify-frontend-flutter/lib/frontend-config-creator.js +++ b/packages/amplify-frontend-flutter/lib/frontend-config-creator.js @@ -241,6 +241,8 @@ function getCognitoConfig(cognitoResources, projectRegion) { }; } + Object.assign(cognitoConfig, cognitoResource.frontEndConfig); + return cognitoConfig; } diff --git a/packages/amplify-frontend-ios/lib/frontend-config-creator.js b/packages/amplify-frontend-ios/lib/frontend-config-creator.js index 14912120709..7d3b81f45ae 100644 --- a/packages/amplify-frontend-ios/lib/frontend-config-creator.js +++ b/packages/amplify-frontend-ios/lib/frontend-config-creator.js @@ -246,6 +246,8 @@ function getCognitoConfig(cognitoResources, projectRegion) { }; } + Object.assign(cognitoCongig, cognitoResource.frontEndConfig); + return cognitoConfig; } diff --git a/packages/amplify-frontend-javascript/lib/frontend-config-creator.js b/packages/amplify-frontend-javascript/lib/frontend-config-creator.js index 9522ef64fa9..b46619b58f0 100644 --- a/packages/amplify-frontend-javascript/lib/frontend-config-creator.js +++ b/packages/amplify-frontend-javascript/lib/frontend-config-creator.js @@ -289,6 +289,30 @@ function getCognitoConfig(cognitoResources, projectRegion) { federationTarget = 'COGNITO_IDENTITY_POOLS'; } + let authData = {}; + + if (cognitoResource.frontEndConfig) { + if (cognitoResource.frontEndConfig.loginMechanism) { + authData.aws_cognito_login_mechanism = cognitoResource.frontEndConfig.loginMechanism; + } + + if (cognitoResource.frontEndConfig.signupAttributes) { + authData.aws_cognito_signup_attributes = cognitoResource.frontEndConfig.signupAttributes; + } + + if (cognitoResource.frontEndConfig.mfaConfiguration) { + authData.aws_cognito_mfa_configuration = cognitoResource.frontEndConfig.mfaConfiguration; + } + + if (cognitoResource.frontEndConfig.mfaTypes) { + authData.aws_cognito_mfa_types = cognitoResource.frontEndConfig.mfaTypes; + } + + if (cognitoResource.frontEndConfig.passwordProtectionSettings) { + authData.aws_cognito_password_protection_settings = cognitoResource.frontEndConfig.passwordProtectionSettings; + } + } + return { aws_cognito_identity_pool_id: cognitoResource.output.IdentityPoolId, aws_cognito_region: projectRegion, @@ -296,6 +320,7 @@ function getCognitoConfig(cognitoResources, projectRegion) { aws_user_pools_web_client_id: cognitoResource.output.AppClientIDWeb, oauth, federationTarget, + ...authData, }; } From 560a951db5dc221248da7cb73d2ce7247d0e644c Mon Sep 17 00:00:00 2001 From: Pavel Lazar Date: Mon, 26 Jul 2021 16:57:52 -0400 Subject: [PATCH 03/15] fix(amplify-category-auth): add auth user selections to aws-exports/amplifyconfiguration files --- packages/amplify-frontend-ios/lib/frontend-config-creator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/amplify-frontend-ios/lib/frontend-config-creator.js b/packages/amplify-frontend-ios/lib/frontend-config-creator.js index 7d3b81f45ae..f070e4d7975 100644 --- a/packages/amplify-frontend-ios/lib/frontend-config-creator.js +++ b/packages/amplify-frontend-ios/lib/frontend-config-creator.js @@ -246,7 +246,7 @@ function getCognitoConfig(cognitoResources, projectRegion) { }; } - Object.assign(cognitoCongig, cognitoResource.frontEndConfig); + Object.assign(cognitoConfig, cognitoResource.frontEndConfig); return cognitoConfig; } From 2680ac81c4900dcc98af1a9c62caa887483036fa Mon Sep 17 00:00:00 2001 From: Pavel Lazar Date: Mon, 26 Jul 2021 22:19:23 -0400 Subject: [PATCH 04/15] fix(amplify-category-auth): added e2e test for add auth user selections to config files --- .circleci/config.yml | 46 +++++++++++++++---- .../src/__tests__/auth_6.test.ts | 44 ++++++++++++++++++ 2 files changed, 82 insertions(+), 8 deletions(-) create mode 100644 packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts diff --git a/.circleci/config.yml b/.circleci/config.yml index e0fe86e1d9b..10d2ce3b1f0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1251,6 +1251,14 @@ jobs: environment: TEST_SUITE: src/__tests__/configure-project.test.ts CLI_REGION: eu-central-1 + auth_6-amplify_e2e_tests: + working_directory: ~/repo + docker: *ref_1 + resource_class: large + steps: *ref_5 + environment: + TEST_SUITE: src/__tests__/auth_6.test.ts + CLI_REGION: ap-northeast-1 api_4-amplify_e2e_tests: working_directory: ~/repo docker: *ref_1 @@ -1258,7 +1266,7 @@ jobs: steps: *ref_5 environment: TEST_SUITE: src/__tests__/api_4.test.ts - CLI_REGION: ap-northeast-1 + CLI_REGION: ap-southeast-1 schema-iterative-update-4-amplify_e2e_tests_pkg_linux: working_directory: ~/repo docker: *ref_1 @@ -1999,6 +2007,16 @@ jobs: TEST_SUITE: src/__tests__/configure-project.test.ts CLI_REGION: eu-central-1 steps: *ref_6 + auth_6-amplify_e2e_tests_pkg_linux: + working_directory: ~/repo + docker: *ref_1 + resource_class: large + environment: + AMPLIFY_DIR: /home/circleci/repo/out + AMPLIFY_PATH: /home/circleci/repo/out/amplify-pkg-linux + TEST_SUITE: src/__tests__/auth_6.test.ts + CLI_REGION: ap-northeast-1 + steps: *ref_6 api_4-amplify_e2e_tests_pkg_linux: working_directory: ~/repo docker: *ref_1 @@ -2007,7 +2025,7 @@ jobs: AMPLIFY_DIR: /home/circleci/repo/out AMPLIFY_PATH: /home/circleci/repo/out/amplify-pkg-linux TEST_SUITE: src/__tests__/api_4.test.ts - CLI_REGION: ap-northeast-1 + CLI_REGION: ap-southeast-1 steps: *ref_6 workflows: version: 2 @@ -2130,11 +2148,11 @@ workflows: - interactions-amplify_e2e_tests - datastore-modelgen-amplify_e2e_tests - layer-2-amplify_e2e_tests - - api_4-amplify_e2e_tests - - schema-iterative-update-2-amplify_e2e_tests + - auth_6-amplify_e2e_tests - schema-data-access-patterns-amplify_e2e_tests - init-special-case-amplify_e2e_tests - iam-permissions-boundary-amplify_e2e_tests + - api_4-amplify_e2e_tests - feature-flags-amplify_e2e_tests - schema-versioned-amplify_e2e_tests - plugin-amplify_e2e_tests @@ -2160,11 +2178,11 @@ workflows: - interactions-amplify_e2e_tests_pkg_linux - datastore-modelgen-amplify_e2e_tests_pkg_linux - layer-2-amplify_e2e_tests_pkg_linux - - api_4-amplify_e2e_tests_pkg_linux - - schema-iterative-update-2-amplify_e2e_tests_pkg_linux + - auth_6-amplify_e2e_tests_pkg_linux - schema-data-access-patterns-amplify_e2e_tests_pkg_linux - init-special-case-amplify_e2e_tests_pkg_linux - iam-permissions-boundary-amplify_e2e_tests_pkg_linux + - api_4-amplify_e2e_tests_pkg_linux - feature-flags-amplify_e2e_tests_pkg_linux - schema-versioned-amplify_e2e_tests_pkg_linux - plugin-amplify_e2e_tests_pkg_linux @@ -2648,7 +2666,7 @@ workflows: filters: *ref_10 requires: - function_3-amplify_e2e_tests - - api_4-amplify_e2e_tests: + - auth_6-amplify_e2e_tests: context: *ref_8 post-steps: *ref_9 filters: *ref_10 @@ -2714,6 +2732,12 @@ workflows: filters: *ref_10 requires: - auth_5-amplify_e2e_tests + - api_4-amplify_e2e_tests: + context: *ref_8 + post-steps: *ref_9 + filters: *ref_10 + requires: + - schema-iterative-update-2-amplify_e2e_tests - schema-iterative-update-3-amplify_e2e_tests: context: *ref_8 post-steps: *ref_9 @@ -3128,7 +3152,7 @@ workflows: filters: *ref_13 requires: - function_3-amplify_e2e_tests_pkg_linux - - api_4-amplify_e2e_tests_pkg_linux: + - auth_6-amplify_e2e_tests_pkg_linux: context: *ref_11 post-steps: *ref_12 filters: *ref_13 @@ -3198,6 +3222,12 @@ workflows: filters: *ref_13 requires: - auth_5-amplify_e2e_tests_pkg_linux + - api_4-amplify_e2e_tests_pkg_linux: + context: *ref_11 + post-steps: *ref_12 + filters: *ref_13 + requires: + - schema-iterative-update-2-amplify_e2e_tests_pkg_linux - schema-iterative-update-3-amplify_e2e_tests_pkg_linux: context: *ref_11 post-steps: *ref_12 diff --git a/packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts b/packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts new file mode 100644 index 00000000000..4a017d1cce0 --- /dev/null +++ b/packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts @@ -0,0 +1,44 @@ +import { + initJSProjectWithProfile, + getProjectMeta, + deleteProject, + amplifyPushAuth, + createNewProjectDir, + deleteProjectDir, + addAuthWithMaxOptions, +} from 'amplify-e2e-core'; +import _ from 'lodash'; + +const PROJECT_NAME = 'authTest'; +const defaultsSettings = { + name: PROJECT_NAME, +}; +describe('zero config auth ', () => { + let projRoot: string; + beforeEach(async () => { + projRoot = await createNewProjectDir('zero-config-auth'); + }); + + afterEach(async () => { + await deleteProject(projRoot); + deleteProjectDir(projRoot); + }); + + it.only('...should init a javascript project and add auth with a all uptions and update front end config', async () => { + await initJSProjectWithProfile(projRoot, defaultsSettings); + await addAuthWithMaxOptions(projRoot, { useInclusiveTerminology: false }); + await amplifyPushAuth(projRoot); + let meta = getProjectMeta(projRoot); + + let id = Object.keys(meta.auth)[0]; + let authMeta = meta.auth[id]; + + expect(authMeta.frontEndConfig).toBeDefined(); + expect(authMeta.frontEndConfig.loginMechanism).toBeDefined(); + expect(authMeta.frontEndConfig.signupAttributes).toBeDefined(); + expect(authMeta.frontEndConfig.mfaConfiguration).toBeDefined(); + expect(authMeta.frontEndConfig.mfaConfiguration).toEqual('ON'); + expect(authMeta.frontEndConfig.mfaTypes).toBeDefined(); + expect(authMeta.frontEndConfig.passwordProtectionSettings).toBeDefined(); + }); +}); From be988f38cceda5afc9cfc36d2b43eb90f564753a Mon Sep 17 00:00:00 2001 From: Pavel Lazar Date: Mon, 26 Jul 2021 22:20:55 -0400 Subject: [PATCH 05/15] fix(amplify-category-auth): added e2e test for add auth user selections to config files --- packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts b/packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts index 4a017d1cce0..2a29724b9c7 100644 --- a/packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts @@ -37,7 +37,6 @@ describe('zero config auth ', () => { expect(authMeta.frontEndConfig.loginMechanism).toBeDefined(); expect(authMeta.frontEndConfig.signupAttributes).toBeDefined(); expect(authMeta.frontEndConfig.mfaConfiguration).toBeDefined(); - expect(authMeta.frontEndConfig.mfaConfiguration).toEqual('ON'); expect(authMeta.frontEndConfig.mfaTypes).toBeDefined(); expect(authMeta.frontEndConfig.passwordProtectionSettings).toBeDefined(); }); From 1e00136984b63c7be0c7eabec3ccae665f8c9a55 Mon Sep 17 00:00:00 2001 From: Pavel Lazar Date: Tue, 27 Jul 2021 10:43:51 -0400 Subject: [PATCH 06/15] fix(amplify-category-auth): added e2e test for add auth user selections to config files --- packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts b/packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts index 2a29724b9c7..5b8eed22943 100644 --- a/packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts @@ -24,7 +24,7 @@ describe('zero config auth ', () => { deleteProjectDir(projRoot); }); - it.only('...should init a javascript project and add auth with a all uptions and update front end config', async () => { + it('...should init a javascript project and add auth with a all uptions and update front end config', async () => { await initJSProjectWithProfile(projRoot, defaultsSettings); await addAuthWithMaxOptions(projRoot, { useInclusiveTerminology: false }); await amplifyPushAuth(projRoot); From 3c9f548b6f5330388d4ecaf783ad0744fa808e6e Mon Sep 17 00:00:00 2001 From: Pavel Lazar Date: Tue, 27 Jul 2021 12:05:36 -0400 Subject: [PATCH 07/15] fix(amplify-category-auth): add auth user selections to config files --- .../amplify-frontend-android/lib/frontend-config-creator.js | 2 +- .../amplify-frontend-flutter/lib/frontend-config-creator.js | 2 +- packages/amplify-frontend-ios/lib/frontend-config-creator.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/amplify-frontend-android/lib/frontend-config-creator.js b/packages/amplify-frontend-android/lib/frontend-config-creator.js index 00f398c5cd2..dc224998f76 100644 --- a/packages/amplify-frontend-android/lib/frontend-config-creator.js +++ b/packages/amplify-frontend-android/lib/frontend-config-creator.js @@ -264,7 +264,7 @@ function getCognitoConfig(cognitoResources, projectRegion) { }; } - Object.assign(cognitoConfig, cognitoResource.frontEndConfig); + Object.assign(cognitoConfig.Auth.Default, cognitoResource.frontEndConfig); return cognitoConfig; } diff --git a/packages/amplify-frontend-flutter/lib/frontend-config-creator.js b/packages/amplify-frontend-flutter/lib/frontend-config-creator.js index 331eab6348f..e28c2b735d5 100644 --- a/packages/amplify-frontend-flutter/lib/frontend-config-creator.js +++ b/packages/amplify-frontend-flutter/lib/frontend-config-creator.js @@ -241,7 +241,7 @@ function getCognitoConfig(cognitoResources, projectRegion) { }; } - Object.assign(cognitoConfig, cognitoResource.frontEndConfig); + Object.assign(cognitoConfig.Auth.Default, cognitoResource.frontEndConfig); return cognitoConfig; } diff --git a/packages/amplify-frontend-ios/lib/frontend-config-creator.js b/packages/amplify-frontend-ios/lib/frontend-config-creator.js index f070e4d7975..ff54a3174ce 100644 --- a/packages/amplify-frontend-ios/lib/frontend-config-creator.js +++ b/packages/amplify-frontend-ios/lib/frontend-config-creator.js @@ -246,7 +246,7 @@ function getCognitoConfig(cognitoResources, projectRegion) { }; } - Object.assign(cognitoConfig, cognitoResource.frontEndConfig); + Object.assign(cognitoConfig.Auth.Default, cognitoResource.frontEndConfig); return cognitoConfig; } From 01b302c06abcff1c5a468b5e37aab903eed4e04a Mon Sep 17 00:00:00 2001 From: Pavel Lazar Date: Tue, 27 Jul 2021 12:49:18 -0400 Subject: [PATCH 08/15] fix(amplify-category-auth): add auth user selections to config files --- .../utils/amplify-meta-updaters.ts | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts index 099b42a2394..e7c533e5aba 100644 --- a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts @@ -1,6 +1,8 @@ import * as path from 'path'; import { JSONUtilities, $TSAny, pathManager } from 'amplify-cli-core'; import { transformUserPoolGroupSchema } from './transform-user-pool-group'; +import { authProviders as authProviderList } from '../assets/string-maps'; + /** * Factory function that returns a function that updates Amplify meta files after adding auth resource assets * @@ -114,18 +116,13 @@ function getFrontEndConfig(authParameters: any) { } if (authParameters.authProviders) { - if (authParameters.authProviders.includes('accounts.google.com')) { - loginMechanism.push('GOOGLE'); - } - if (authParameters.authProviders.includes('graph.facebook.com')) { - loginMechanism.push('FACEBOOK'); - } - if (authParameters.authProviders.includes('www.amazon.com')) { - loginMechanism.push('AMAZON'); - } - if (authParameters.authProviders.includes('appleid.apple.com')) { - loginMechanism.push('APPLE'); - } + authParameters.authProviders.forEach((provider: string) => { + let name = authProviderList.find(it => it.value === provider)?.name; + + if (name) { + loginMechanism.push(name.toUpperCase()); + } + }); } if (loginMechanism.length) { From d004867f5710fdfe610f268ddb5fc3a2d4e034e7 Mon Sep 17 00:00:00 2001 From: Pavel Lazar Date: Tue, 27 Jul 2021 19:09:51 -0400 Subject: [PATCH 09/15] chore(amplify-category-auth): cr feedback for add auth user selections to config files --- .../src/__tests__/auth_6.test.ts | 57 +++++++++++++------ 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts b/packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts index 5b8eed22943..9a77dbb7e9c 100644 --- a/packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts @@ -1,16 +1,16 @@ +import { $TSAny } from 'amplify-cli-core'; import { - initJSProjectWithProfile, - getProjectMeta, - deleteProject, + addAuthWithMaxOptions, amplifyPushAuth, createNewProjectDir, + deleteProject, deleteProjectDir, - addAuthWithMaxOptions, + getProjectMeta, + initJSProjectWithProfile, } from 'amplify-e2e-core'; -import _ from 'lodash'; const PROJECT_NAME = 'authTest'; -const defaultsSettings = { +const defaultSettings = { name: PROJECT_NAME, }; describe('zero config auth ', () => { @@ -24,20 +24,41 @@ describe('zero config auth ', () => { deleteProjectDir(projRoot); }); - it('...should init a javascript project and add auth with a all uptions and update front end config', async () => { - await initJSProjectWithProfile(projRoot, defaultsSettings); - await addAuthWithMaxOptions(projRoot, { useInclusiveTerminology: false }); + it('...should init a javascript project and add auth with a all options and update front end config', async () => { + await initJSProjectWithProfile(projRoot, defaultSettings); + await addAuthWithMaxOptions(projRoot, {}); await amplifyPushAuth(projRoot); - let meta = getProjectMeta(projRoot); - let id = Object.keys(meta.auth)[0]; - let authMeta = meta.auth[id]; + const meta = getProjectMeta(projRoot); + const authMeta: $TSAny = Object.values(meta.auth)[0]; - expect(authMeta.frontEndConfig).toBeDefined(); - expect(authMeta.frontEndConfig.loginMechanism).toBeDefined(); - expect(authMeta.frontEndConfig.signupAttributes).toBeDefined(); - expect(authMeta.frontEndConfig.mfaConfiguration).toBeDefined(); - expect(authMeta.frontEndConfig.mfaTypes).toBeDefined(); - expect(authMeta.frontEndConfig.passwordProtectionSettings).toBeDefined(); + expect(authMeta.frontendAuthConfig).toMatchInlineSnapshot(` + { + "loginMechanism": [ + "EMAIL", + "FACEBOOK", + "GOOGLE", + "AMAZON", + "APPLE" + ], + "signupAttributes": [ + "EMAIL" + ], + "passwordProtectionSettings": { + "passwordPolicyMinLength": 8, + "passwordPolicyCharacters": [ + "REQUIRES_LOWERCASE", + "REQUIRES_UPPERCASE", + "REQUIRES_NUMBERS", + "REQUIRES_SYMBOLS" + ] + }, + "mfaConfiguration": "ON", + "mfaTypes": [ + "SMS", + "TOTP" + ] + } + `); }); }); From ef07445c76d37336f5f5f702bd4597f8e8f0b784 Mon Sep 17 00:00:00 2001 From: Pavel Lazar Date: Tue, 27 Jul 2021 19:10:30 -0400 Subject: [PATCH 10/15] chore(amplify-category-auth): cr feedback for add auth user selections to config files --- .../awscloudformation/import/types.ts | 13 ++++ .../utils/amplify-meta-updaters.ts | 73 +++++++------------ .../lib/frontend-config-creator.js | 2 +- .../lib/frontend-config-creator.js | 2 +- .../lib/frontend-config-creator.js | 2 +- .../lib/frontend-config-creator.js | 33 +++------ 6 files changed, 54 insertions(+), 71 deletions(-) diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/import/types.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/import/types.ts index a05f3ab1baa..ad358b5ba83 100644 --- a/packages/amplify-category-auth/src/provider-utils/awscloudformation/import/types.ts +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/import/types.ts @@ -50,6 +50,19 @@ export type MetaOutput = { CreatedSNSRole?: string; }; +export type AuthParameters = { + dependsOn?: any[]; + triggers?: string; + identityPoolName?: string; + aliasAttributes?: string[]; + authProviders?: string[]; + requiredAttributes?: string[]; + passwordPolicyMinLength?: string; + passwordPolicyCharacters?: string[]; + mfaConfiguration?: string; + mfaTypes?: string[]; +}; + // Persisted into team-provider-info export type EnvSpecificResourceParameters = { userPoolId: string; diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts index e7c533e5aba..799028df85f 100644 --- a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts @@ -1,7 +1,8 @@ import * as path from 'path'; -import { JSONUtilities, $TSAny, pathManager } from 'amplify-cli-core'; +import { JSONUtilities, pathManager } from 'amplify-cli-core'; import { transformUserPoolGroupSchema } from './transform-user-pool-group'; import { authProviders as authProviderList } from '../assets/string-maps'; +import { AuthParameters } from '../import/types'; /** * Factory function that returns a function that updates Amplify meta files after adding auth resource assets @@ -18,7 +19,7 @@ export const getPostAddAuthMetaUpdater = (context: any, resultMetadata: { servic providerPlugin: resultMetadata.providerName, }; const parametersJSONPath = path.join(context.amplify.pathManager.getBackendDirPath(), 'auth', resourceName, 'parameters.json'); - const authParameters = JSONUtilities.readJson<$TSAny>(parametersJSONPath)!; + const authParameters = JSONUtilities.readJson(parametersJSONPath)!; if (authParameters.dependsOn) { options.dependsOn = authParameters.dependsOn; @@ -38,7 +39,7 @@ export const getPostAddAuthMetaUpdater = (context: any, resultMetadata: { servic } options.customAuth = customAuthConfigured; - options.frontEndConfig = getFrontEndConfig(authParameters); + options.frontendAuthConfig = getFrontEndConfig(authParameters); context.amplify.updateamplifyMetaAfterResourceAdd('auth', resourceName, options); @@ -65,7 +66,7 @@ export const getPostAddAuthMetaUpdater = (context: any, resultMetadata: { servic */ export const getPostUpdateAuthMetaUpdater = (context: any) => async (resourceName: string) => { const resourceDirPath = path.join(pathManager.getBackendDirPath(), 'auth', resourceName, 'parameters.json'); - const authParameters = JSONUtilities.readJson<$TSAny>(resourceDirPath); + const authParameters = JSONUtilities.readJson(resourceDirPath)!; if (authParameters.dependsOn) { context.amplify.updateamplifyMetaAfterResourceUpdate('auth', resourceName, 'dependsOn', authParameters.dependsOn); } @@ -82,7 +83,7 @@ export const getPostUpdateAuthMetaUpdater = (context: any) => async (resourceNam triggers.VerifyAuthChallengeResponse.length > 0; } context.amplify.updateamplifyMetaAfterResourceUpdate('auth', resourceName, 'customAuth', customAuthConfigured); - context.amplify.updateamplifyMetaAfterResourceUpdate('auth', resourceName, 'frontEndConfig', getFrontEndConfig(authParameters)); + context.amplify.updateamplifyMetaAfterResourceUpdate('auth', resourceName, 'frontendAuthConfig', getFrontEndConfig(authParameters)); // Update Identity Pool dependency attributes on userpool groups const allResources = context.amplify.getProjectMeta(); @@ -105,15 +106,9 @@ export const getPostUpdateAuthMetaUpdater = (context: any) => async (resourceNam return resourceName; }; -function getFrontEndConfig(authParameters: any) { - const frontEndConfig: any = {}; - - let loginMechanism: string[] = []; - - if (authParameters.aliasAttributes) { - let aliasAttributes = authParameters.aliasAttributes.map((att: string) => att.toUpperCase()); - loginMechanism = [...aliasAttributes]; - } +function getFrontEndConfig(authParameters: AuthParameters) { + const loginMechanism: string[] = []; + loginMechanism.push(...(authParameters?.aliasAttributes || []).map((att: string) => att.toUpperCase())); if (authParameters.authProviders) { authParameters.authProviders.forEach((provider: string) => { @@ -125,45 +120,33 @@ function getFrontEndConfig(authParameters: any) { }); } - if (loginMechanism.length) { - frontEndConfig.loginMechanism = loginMechanism; - } + const signupAttributes: string[] = authParameters?.requiredAttributes + ? authParameters.requiredAttributes.map((att: string) => att.toUpperCase()) + : []; - if (authParameters.requiredAttributes) { - let requiredAttributes = authParameters.requiredAttributes.map((att: string) => att.toUpperCase()); - frontEndConfig.signupAttributes = [...requiredAttributes]; - } - - if (authParameters.mfaConfiguration) { - frontEndConfig.mfaConfiguration = authParameters.mfaConfiguration; - } + const passwordProtectionSettings = { + passwordPolicyMinLength: authParameters?.passwordPolicyMinLength, + passwordPolicyCharacters: authParameters?.passwordPolicyCharacters + ? authParameters.passwordPolicyCharacters.map((i: string) => i.replace(/ /g, '_').toUpperCase()) + : [], + }; + const mfaTypes: string[] = []; if (authParameters.mfaTypes) { - frontEndConfig.mfaTypes = []; - if (authParameters.mfaTypes.includes('SMS Text Message')) { - frontEndConfig.mfaTypes.push('SMS'); + mfaTypes.push('SMS'); } if (authParameters.mfaTypes.includes('TOTP')) { - frontEndConfig.mfaTypes.push('TOTP'); + mfaTypes.push('TOTP'); } } - if (authParameters.passwordPolicyMinLength || authParameters.passwordPolicyCharacters) { - let passwordProtectionSettings: any = {}; - - if (authParameters.passwordPolicyMinLength) { - passwordProtectionSettings.passwordPolicyMinLength = authParameters.passwordPolicyMinLength; - } - - if (authParameters.passwordPolicyCharacters) { - let passwordPolicyCharacters = authParameters.passwordPolicyCharacters.map((i: string) => i.replace(/ /g, '_').toUpperCase()); - passwordProtectionSettings.passwordPolicyCharacters = passwordPolicyCharacters; - } - - frontEndConfig.passwordProtectionSettings = passwordProtectionSettings; - } - - return frontEndConfig; + return { + loginMechanism: loginMechanism, + signupAttributes: signupAttributes, + passwordProtectionSettings: passwordProtectionSettings, + mfaConfiguration: authParameters?.mfaConfiguration, + mfaTypes: mfaTypes, + }; } diff --git a/packages/amplify-frontend-android/lib/frontend-config-creator.js b/packages/amplify-frontend-android/lib/frontend-config-creator.js index dc224998f76..f7103cfcb78 100644 --- a/packages/amplify-frontend-android/lib/frontend-config-creator.js +++ b/packages/amplify-frontend-android/lib/frontend-config-creator.js @@ -264,7 +264,7 @@ function getCognitoConfig(cognitoResources, projectRegion) { }; } - Object.assign(cognitoConfig.Auth.Default, cognitoResource.frontEndConfig); + Object.assign(cognitoConfig.Auth.Default, cognitoResource.frontendAuthConfig); return cognitoConfig; } diff --git a/packages/amplify-frontend-flutter/lib/frontend-config-creator.js b/packages/amplify-frontend-flutter/lib/frontend-config-creator.js index e28c2b735d5..aea9c7eb175 100644 --- a/packages/amplify-frontend-flutter/lib/frontend-config-creator.js +++ b/packages/amplify-frontend-flutter/lib/frontend-config-creator.js @@ -241,7 +241,7 @@ function getCognitoConfig(cognitoResources, projectRegion) { }; } - Object.assign(cognitoConfig.Auth.Default, cognitoResource.frontEndConfig); + Object.assign(cognitoConfig.Auth.Default, cognitoResource.frontendAuthConfig); return cognitoConfig; } diff --git a/packages/amplify-frontend-ios/lib/frontend-config-creator.js b/packages/amplify-frontend-ios/lib/frontend-config-creator.js index ff54a3174ce..1969134f8fa 100644 --- a/packages/amplify-frontend-ios/lib/frontend-config-creator.js +++ b/packages/amplify-frontend-ios/lib/frontend-config-creator.js @@ -246,7 +246,7 @@ function getCognitoConfig(cognitoResources, projectRegion) { }; } - Object.assign(cognitoConfig.Auth.Default, cognitoResource.frontEndConfig); + Object.assign(cognitoConfig.Auth.Default, cognitoResource.frontendAuthConfig); return cognitoConfig; } diff --git a/packages/amplify-frontend-javascript/lib/frontend-config-creator.js b/packages/amplify-frontend-javascript/lib/frontend-config-creator.js index b46619b58f0..412a0f45ecd 100644 --- a/packages/amplify-frontend-javascript/lib/frontend-config-creator.js +++ b/packages/amplify-frontend-javascript/lib/frontend-config-creator.js @@ -289,28 +289,15 @@ function getCognitoConfig(cognitoResources, projectRegion) { federationTarget = 'COGNITO_IDENTITY_POOLS'; } - let authData = {}; - - if (cognitoResource.frontEndConfig) { - if (cognitoResource.frontEndConfig.loginMechanism) { - authData.aws_cognito_login_mechanism = cognitoResource.frontEndConfig.loginMechanism; - } - - if (cognitoResource.frontEndConfig.signupAttributes) { - authData.aws_cognito_signup_attributes = cognitoResource.frontEndConfig.signupAttributes; - } - - if (cognitoResource.frontEndConfig.mfaConfiguration) { - authData.aws_cognito_mfa_configuration = cognitoResource.frontEndConfig.mfaConfiguration; - } - - if (cognitoResource.frontEndConfig.mfaTypes) { - authData.aws_cognito_mfa_types = cognitoResource.frontEndConfig.mfaTypes; - } - - if (cognitoResource.frontEndConfig.passwordProtectionSettings) { - authData.aws_cognito_password_protection_settings = cognitoResource.frontEndConfig.passwordProtectionSettings; - } + let frontendAuthConfig; + if (cognitoResource && cognitoResource.frontEndConfig) { + frontendAuthConfig = { + aws_cognito_login_mechanism: cognitoResource.frontEndConfig.loginMechanism, + aws_cognito_signup_attributes: cognitoResource.frontEndConfig.signupAttributes, + aws_cognito_mfa_configuration: cognitoResource.frontEndConfig.mfaConfiguration, + aws_cognito_mfa_types: cognitoResource.frontEndConfig.mfaTypes, + aws_cognito_password_protection_settings: cognitoResource.frontEndConfig.passwordProtectionSettings, + }; } return { @@ -320,7 +307,7 @@ function getCognitoConfig(cognitoResources, projectRegion) { aws_user_pools_web_client_id: cognitoResource.output.AppClientIDWeb, oauth, federationTarget, - ...authData, + ...frontendAuthConfig, }; } From 98aacfd3870adf81635a18c2048bf783866080b9 Mon Sep 17 00:00:00 2001 From: Pavel Lazar Date: Tue, 27 Jul 2021 23:49:22 -0400 Subject: [PATCH 11/15] chore(amplify-category-auth): typo fix --- packages/amplify-e2e-core/src/categories/auth.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/amplify-e2e-core/src/categories/auth.ts b/packages/amplify-e2e-core/src/categories/auth.ts index d35c55812e5..782153a439d 100644 --- a/packages/amplify-e2e-core/src/categories/auth.ts +++ b/packages/amplify-e2e-core/src/categories/auth.ts @@ -1290,7 +1290,7 @@ export function addAuthUserPoolOnlyWithOAuth(cwd: string, settings: AddAuthUserP .wait('Do you want to add another redirect signout URI') .sendConfirmNo() .wait('Select the OAuth flows enabled for this project') - .sendCarriageReturn() // Authorication Grant + .sendCarriageReturn() // Authorization Grant .wait('Select the OAuth scopes enabled for this project') .sendCarriageReturn() // All .wait('Select the social providers you want to configure for your user pool') @@ -1414,7 +1414,7 @@ export function addAuthIdentityPoolAndUserPoolWithOAuth( .wait('Do you want to add another redirect signout URI') .sendConfirmNo() .wait('Select the OAuth flows enabled for this project') - .sendCarriageReturn() // Authorication Grant + .sendCarriageReturn() // Authorization Grant .wait('Select the OAuth scopes enabled for this project') .sendCarriageReturn() // All .wait('Select the social providers you want to configure for your user pool') From e7ef8461e61667bf1707787815b642b3a85aaad3 Mon Sep 17 00:00:00 2001 From: Pavel Lazar Date: Wed, 28 Jul 2021 13:03:51 -0400 Subject: [PATCH 12/15] chore(amplify-category-auth): fixed e2e test for front end config validation --- .../src/__tests__/auth_6.test.ts | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts b/packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts index 9a77dbb7e9c..ae6c727a108 100644 --- a/packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/auth_6.test.ts @@ -24,40 +24,40 @@ describe('zero config auth ', () => { deleteProjectDir(projRoot); }); - it('...should init a javascript project and add auth with a all options and update front end config', async () => { + it('...should init a javascript project and add auth with all options and update front end config', async () => { await initJSProjectWithProfile(projRoot, defaultSettings); await addAuthWithMaxOptions(projRoot, {}); await amplifyPushAuth(projRoot); const meta = getProjectMeta(projRoot); - const authMeta: $TSAny = Object.values(meta.auth)[0]; + const authMeta: $TSAny = Object.values(meta.auth)[1]; expect(authMeta.frontendAuthConfig).toMatchInlineSnapshot(` - { - "loginMechanism": [ + Object { + "loginMechanism": Array [ "EMAIL", "FACEBOOK", "GOOGLE", "AMAZON", - "APPLE" + "APPLE", ], - "signupAttributes": [ - "EMAIL" + "mfaConfiguration": "ON", + "mfaTypes": Array [ + "SMS", + "TOTP", ], - "passwordProtectionSettings": { - "passwordPolicyMinLength": 8, - "passwordPolicyCharacters": [ + "passwordProtectionSettings": Object { + "passwordPolicyCharacters": Array [ "REQUIRES_LOWERCASE", "REQUIRES_UPPERCASE", "REQUIRES_NUMBERS", - "REQUIRES_SYMBOLS" - ] + "REQUIRES_SYMBOLS", + ], + "passwordPolicyMinLength": 8, }, - "mfaConfiguration": "ON", - "mfaTypes": [ - "SMS", - "TOTP" - ] + "signupAttributes": Array [ + "EMAIL", + ], } `); }); From aa13f1d58508a74cd61f8b8c9fa59e5d106521e4 Mon Sep 17 00:00:00 2001 From: lazpavel <85319655+lazpavel@users.noreply.github.com> Date: Wed, 28 Jul 2021 21:20:21 -0400 Subject: [PATCH 13/15] Update packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts Co-authored-by: Edward Foyle --- .../awscloudformation/utils/amplify-meta-updaters.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts index 799028df85f..f805af8943d 100644 --- a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts @@ -120,9 +120,7 @@ function getFrontEndConfig(authParameters: AuthParameters) { }); } - const signupAttributes: string[] = authParameters?.requiredAttributes - ? authParameters.requiredAttributes.map((att: string) => att.toUpperCase()) - : []; +const signupAttributes = (authParameters?.requiredAttributes || []).map((att: string) => att.toUpperCase()); const passwordProtectionSettings = { passwordPolicyMinLength: authParameters?.passwordPolicyMinLength, From 496fd46d24389ad889b92f72914571be36f7af79 Mon Sep 17 00:00:00 2001 From: Pavel Lazar Date: Wed, 28 Jul 2021 22:03:45 -0400 Subject: [PATCH 14/15] chore(amplify-category-auth): addressed pr feedback --- .../utils/amplify-meta-updaters.ts | 12 +++++------- .../lib/frontend-config-creator.js | 16 +++++++--------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts index f805af8943d..80fe5e03425 100644 --- a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/amplify-meta-updaters.ts @@ -39,7 +39,7 @@ export const getPostAddAuthMetaUpdater = (context: any, resultMetadata: { servic } options.customAuth = customAuthConfigured; - options.frontendAuthConfig = getFrontEndConfig(authParameters); + options.frontendAuthConfig = getFrontendConfig(authParameters); context.amplify.updateamplifyMetaAfterResourceAdd('auth', resourceName, options); @@ -83,7 +83,7 @@ export const getPostUpdateAuthMetaUpdater = (context: any) => async (resourceNam triggers.VerifyAuthChallengeResponse.length > 0; } context.amplify.updateamplifyMetaAfterResourceUpdate('auth', resourceName, 'customAuth', customAuthConfigured); - context.amplify.updateamplifyMetaAfterResourceUpdate('auth', resourceName, 'frontendAuthConfig', getFrontEndConfig(authParameters)); + context.amplify.updateamplifyMetaAfterResourceUpdate('auth', resourceName, 'frontendAuthConfig', getFrontendConfig(authParameters)); // Update Identity Pool dependency attributes on userpool groups const allResources = context.amplify.getProjectMeta(); @@ -106,7 +106,7 @@ export const getPostUpdateAuthMetaUpdater = (context: any) => async (resourceNam return resourceName; }; -function getFrontEndConfig(authParameters: AuthParameters) { +function getFrontendConfig(authParameters: AuthParameters) { const loginMechanism: string[] = []; loginMechanism.push(...(authParameters?.aliasAttributes || []).map((att: string) => att.toUpperCase())); @@ -120,13 +120,11 @@ function getFrontEndConfig(authParameters: AuthParameters) { }); } -const signupAttributes = (authParameters?.requiredAttributes || []).map((att: string) => att.toUpperCase()); + const signupAttributes = (authParameters?.requiredAttributes || []).map((att: string) => att.toUpperCase()); const passwordProtectionSettings = { passwordPolicyMinLength: authParameters?.passwordPolicyMinLength, - passwordPolicyCharacters: authParameters?.passwordPolicyCharacters - ? authParameters.passwordPolicyCharacters.map((i: string) => i.replace(/ /g, '_').toUpperCase()) - : [], + passwordPolicyCharacters: (authParameters?.passwordPolicyCharacters || []).map((i: string) => i.replace(/ /g, '_').toUpperCase()), }; const mfaTypes: string[] = []; diff --git a/packages/amplify-frontend-javascript/lib/frontend-config-creator.js b/packages/amplify-frontend-javascript/lib/frontend-config-creator.js index 412a0f45ecd..6e7d2e47404 100644 --- a/packages/amplify-frontend-javascript/lib/frontend-config-creator.js +++ b/packages/amplify-frontend-javascript/lib/frontend-config-creator.js @@ -289,15 +289,13 @@ function getCognitoConfig(cognitoResources, projectRegion) { federationTarget = 'COGNITO_IDENTITY_POOLS'; } - let frontendAuthConfig; - if (cognitoResource && cognitoResource.frontEndConfig) { - frontendAuthConfig = { - aws_cognito_login_mechanism: cognitoResource.frontEndConfig.loginMechanism, - aws_cognito_signup_attributes: cognitoResource.frontEndConfig.signupAttributes, - aws_cognito_mfa_configuration: cognitoResource.frontEndConfig.mfaConfiguration, - aws_cognito_mfa_types: cognitoResource.frontEndConfig.mfaTypes, - aws_cognito_password_protection_settings: cognitoResource.frontEndConfig.passwordProtectionSettings, - }; + const frontendAuthConfig = {}; + if (cognitoResource.frontendAuthConfig) { + frontendAuthConfig.aws_cognito_login_mechanism = cognitoResource.frontendAuthConfig.loginMechanism; + frontendAuthConfig.aws_cognito_signup_attributes = cognitoResource.frontendAuthConfig.signupAttributes; + frontendAuthConfig.aws_cognito_mfa_configuration = cognitoResource.frontendAuthConfig.mfaConfiguration; + frontendAuthConfig.aws_cognito_mfa_types = cognitoResource.frontendAuthConfig.mfaTypes; + frontendAuthConfig.aws_cognito_password_protection_settings = cognitoResource.frontendAuthConfig.passwordProtectionSettings; } return { From d2e1bea8719a5b7f277574c2dd1d0a4278996e9b Mon Sep 17 00:00:00 2001 From: Pavel Lazar Date: Thu, 29 Jul 2021 13:23:41 -0400 Subject: [PATCH 15/15] chore(amplify-category-auth): changed dependsOn type from any to --- .../src/provider-utils/awscloudformation/import/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/import/types.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/import/types.ts index ad358b5ba83..84fea969dec 100644 --- a/packages/amplify-category-auth/src/provider-utils/awscloudformation/import/types.ts +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/import/types.ts @@ -1,4 +1,4 @@ -import { $TSContext, $TSObject } from 'amplify-cli-core'; +import { $TSAny, $TSContext, $TSObject } from 'amplify-cli-core'; import { GetUserPoolMfaConfigResponse, IdentityProviderType, @@ -51,7 +51,7 @@ export type MetaOutput = { }; export type AuthParameters = { - dependsOn?: any[]; + dependsOn?: $TSAny[]; triggers?: string; identityPoolName?: string; aliasAttributes?: string[];