From 5a77481b9f2f360667992f9022c48e409b99097d Mon Sep 17 00:00:00 2001 From: Yathi <511386+yuth@users.noreply.github.com> Date: Fri, 16 Apr 2021 15:50:33 -0700 Subject: [PATCH] fix: render the right auth mode for admin queries in config files Updated the frontend config files to have the correct authorization type for AdminQueries fix #6983 --- .../awscloudformation/utils/synthesize-resources.ts | 1 + .../amplify-frontend-android/lib/amplify-config-helper.js | 2 +- .../amplify-frontend-flutter/lib/amplify-config-helper.js | 4 ++-- packages/amplify-frontend-ios/lib/amplify-config-helper.js | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/synthesize-resources.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/synthesize-resources.ts index bd6697d5b7a..158fddeb974 100644 --- a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/synthesize-resources.ts +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/synthesize-resources.ts @@ -405,6 +405,7 @@ const createAdminAuthAPI = async (context: any, authResourceName: string, functi const backendConfigs = { service: 'API Gateway', providerPlugin: 'awscloudformation', + authorizationType: 'AMAZON_COGNITO_USER_POOLS', dependsOn, }; diff --git a/packages/amplify-frontend-android/lib/amplify-config-helper.js b/packages/amplify-frontend-android/lib/amplify-config-helper.js index 64f55040fef..59edc9e233e 100644 --- a/packages/amplify-frontend-android/lib/amplify-config-helper.js +++ b/packages/amplify-frontend-android/lib/amplify-config-helper.js @@ -77,7 +77,7 @@ function constructApi(metadata, amplifyConfig) { endpointType: 'REST', endpoint: resourceMeta.output.RootUrl, region, - authorizationType: 'AWS_IAM', + authorizationType: resourceMeta.authorizationType || 'AWS_IAM', }; } else if (resourceMeta.service === 'ElasticContainer' && resourceMeta.apiType === 'REST') { amplifyConfig[categoryName].plugins[pluginName][r] = { diff --git a/packages/amplify-frontend-flutter/lib/amplify-config-helper.js b/packages/amplify-frontend-flutter/lib/amplify-config-helper.js index db112e8bddd..36ee8b32952 100644 --- a/packages/amplify-frontend-flutter/lib/amplify-config-helper.js +++ b/packages/amplify-frontend-flutter/lib/amplify-config-helper.js @@ -76,14 +76,14 @@ function constructApi(metadata, amplifyConfig) { endpointType: 'REST', endpoint: resourceMeta.output.RootUrl, region, - authorizationType: 'AWS_IAM', + authorizationType: resourceMeta.authorizationType || 'AWS_IAM', }; } else if (resourceMeta.service === 'ElasticContainer' && resourceMeta.apiType === 'REST') { amplifyConfig[categoryName].plugins[pluginName][r] = { endpointType: 'REST', endpoint: resourceMeta.output.RootUrl, region, - authorizationType: resourceMeta.restrictAccess ? "AMAZON_COGNITO_USER_POOLS" : "AWS_IAM", + authorizationType: resourceMeta.restrictAccess ? 'AMAZON_COGNITO_USER_POOLS' : 'AWS_IAM', }; } } diff --git a/packages/amplify-frontend-ios/lib/amplify-config-helper.js b/packages/amplify-frontend-ios/lib/amplify-config-helper.js index fd541239fc5..59edc9e233e 100644 --- a/packages/amplify-frontend-ios/lib/amplify-config-helper.js +++ b/packages/amplify-frontend-ios/lib/amplify-config-helper.js @@ -77,14 +77,14 @@ function constructApi(metadata, amplifyConfig) { endpointType: 'REST', endpoint: resourceMeta.output.RootUrl, region, - authorizationType: 'AWS_IAM', + authorizationType: resourceMeta.authorizationType || 'AWS_IAM', }; } else if (resourceMeta.service === 'ElasticContainer' && resourceMeta.apiType === 'REST') { amplifyConfig[categoryName].plugins[pluginName][r] = { endpointType: 'REST', endpoint: resourceMeta.output.RootUrl, region, - authorizationType: resourceMeta.restrictAccess ? "AMAZON_COGNITO_USER_POOLS" : "AWS_IAM", + authorizationType: resourceMeta.restrictAccess ? 'AMAZON_COGNITO_USER_POOLS' : 'AWS_IAM', }; } }