Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit length of cognito user pool prefix to 63 #2343

Merged
merged 4 commits into from
Jun 20, 2024

Conversation

philmcmahon
Copy link
Contributor

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:

@philmcmahon philmcmahon requested a review from a team as a code owner June 18, 2024 11:57
Copy link

changeset-bot bot commented Jun 18, 2024

🦋 Changeset detected

Latest commit: 9533976

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@guardian/cdk Patch

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

Copy link
Member

@AshCorr AshCorr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Don't forget a changeset!

@philmcmahon philmcmahon force-pushed the pm-limit-userpool-domainprefix branch from 96ffd7d to 9533976 Compare June 20, 2024 11:16
@philmcmahon philmcmahon enabled auto-merge June 20, 2024 11:16
@philmcmahon philmcmahon merged commit 7170a71 into main Jun 20, 2024
4 checks passed
@philmcmahon philmcmahon deleted the pm-limit-userpool-domainprefix branch June 20, 2024 11:19
@philmcmahon philmcmahon restored the pm-limit-userpool-domainprefix branch June 20, 2024 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants