From bcdce1e8c0928305e1cdfa0308df4be6dcbac9b7 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 7 Jul 2021 09:19:47 -0700 Subject: [PATCH] fix(amplify-category-auth): check for siwa Cognito idp params (#7678) Need to check for siwa params because privateKey is not returned from Cognito, so it may not always be available. Worst case the user will need to re-configure SIWA in a new environment for amplify init. Co-authored-by: David Lopez --- .../auth-template.yml.ejs | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/packages/amplify-category-auth/resources/cloudformation-templates/auth-template.yml.ejs b/packages/amplify-category-auth/resources/cloudformation-templates/auth-template.yml.ejs index a6b89c10c56..e3f31d0b3e1 100644 --- a/packages/amplify-category-auth/resources/cloudformation-templates/auth-template.yml.ejs +++ b/packages/amplify-category-auth/resources/cloudformation-templates/auth-template.yml.ejs @@ -594,13 +594,17 @@ Resources: - ' AttributeMapping: providerMeta.AttributeMapping,' - ' };' - ' if (providerMeta.ProviderName === ''SignInWithApple'') {' - - ' requestParams.ProviderDetails = {' - - ' ''client_id'': providerCreds.client_id,' - - ' ''team_id'': providerCreds.team_id,' - - ' ''key_id'': providerCreds.key_id,' - - ' ''private_key'': providerCreds.private_key,' - - ' ''authorize_scopes'': providerMeta.authorize_scopes,' - - ' };' + - ' if (providerCreds.client_id && providerCreds.team_id && providerCreds.key_id && providerCreds.private_key) {' + - ' requestParams.ProviderDetails = {' + - ' ''client_id'': providerCreds.client_id,' + - ' ''team_id'': providerCreds.team_id,' + - ' ''key_id'': providerCreds.key_id,' + - ' ''private_key'': providerCreds.private_key,' + - ' ''authorize_scopes'': providerMeta.authorize_scopes,' + - ' };' + - ' } else {' + - ' requestParams = null;' + - ' }' - ' } else {' - ' requestParams.ProviderDetails = {' - ' ''client_id'': providerCreds.client_id,' @@ -612,11 +616,17 @@ Resources: - ' };' - ' let createIdentityProvider = (providerName) => {' - ' let requestParams = getRequestParams(providerName);' + - ' if (!requestParams) {' + - ' return Promise.resolve();' + - ' }' - ' requestParams.ProviderType = requestParams.ProviderName;' - ' return identity.createIdentityProvider(requestParams).promise();' - ' };' - ' let updateIdentityProvider = (providerName) => {' - ' let requestParams = getRequestParams(providerName);' + - ' if (!requestParams) {' + - ' return Promise.resolve();' + - ' }' - ' return identity.updateIdentityProvider(requestParams).promise();' - ' };' - ' let deleteIdentityProvider = (providerName) => {'