Skip to content

Limit length of cognito user pool prefix to 63#2343

Merged
philmcmahon merged 4 commits intomainfrom
pm-limit-userpool-domainprefix
Jun 20, 2024
Merged

Limit length of cognito user pool prefix to 63#2343
philmcmahon merged 4 commits intomainfrom
pm-limit-userpool-domainprefix

Conversation

@philmcmahon
Copy link
Copy Markdown
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
@changeset-bot
Copy link
Copy Markdown

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
Copy Markdown
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
@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