feat(auth): support custom domain for external identity provider #3063
+184
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The problem is articulated well in #2350. Currently, when leveraging external identity providers in an Amplify app, it is not allowed to specify a custom domain. As a result, when app customers login with the external identity provider such as Google, they are prompted with a cryptic domain name such as
db049484d0476df65368.auth.us-east-1.amazoncognito.com. This cryptic domain name is not trust-inspiring and prevents the customers from further using the app.This PR adds support for creating a custom domain for the user pool. Instead of the cryptic domain name, developer of the Amplify app can provide a custom domain associated with their own brand.
Please note that this PR is different from #3056. #3056 allows developers to specify a custom
domain prefix, so that the customers of the Amplify app will be prompted with a domain name such as<your-app>.auth.us-east-1.amazoncognito.com. Meanwhile this PR allows developers to specify a completecustom domainfor the user pool, so that their customers will be prompted with<your-app>.com.Issue number, if available:
#2350
Changes
customDomainOptions?: CustomDomainOptionsfor typeExternalProviderOptionsinpackages/auth-construct/src/types.tsfor necessary information needed to create a custom domain.setupCustomDomaininpackages/auth-construct/src/construct.tsto create the custom domain and necessary resources for the external identity provider login workflow by following this AWS Cognito instruction.packages/auth-construct/src/construct.tsto use the custom domain domain name inamplify_outputs.jsonif the custom domain is created.With this PR, the developer can specify and create custom domain as part of
defineAuthin the following wayCorresponding docs PR, if applicable:
Validation
I added unit tests to cover this change. I also tested this change locally with my Amplify app.
Checklist
run-e2elabel set.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.