Limit length of cognito user pool prefix to 63#2343
Merged
philmcmahon merged 4 commits intomainfrom Jun 20, 2024
Merged
Conversation
🦋 Changeset detectedLatest commit: 9533976 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
AshCorr
approved these changes
Jun 19, 2024
Member
AshCorr
left a comment
There was a problem hiding this comment.
Looks good! Don't forget a changeset!
96ffd7d to
9533976
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this change?
I recently ran into an issue when trying to add googleAuth to a project with a rather long app name:
1 validation error detected: Value 'com-gu-myvery-looong-appname-prod-6ead8aa1447b718dd224f9eab2808b25' at 'domain' failed to satisfy constraint: Member must have length less than or equal to 63 (Service: AWSCognitoIdentityProviderService; Status Code: 400; Error Code: InvalidParameterException; Request ID: f58fe6de-1cf3-44a2-8498-a3afaca5bd3b; Proxy: null)This change attempts to resolve the issue by trimming the generated domain prefix to 63 chars. I'm making an assumption that a 5 char hash will be enough to ensure uniqueness (the current md5 hash is 32 chars).
The important thing here is that we don't want to change the domainPrefix of any existing cognito user pools, which is why I'm only trimming the domainPrefix when the length is greater than 63.
How to test
I've added a few unit tests - see what you think. I tested against the offending project and was able to succesfully set up google auth: