Restricting Users to Specific Domains in AWS Cognito

If you want to restrict access to your AWS Cognito user pool to only a specific company’s domain, you can follow these steps:

Step 1. Create a Lambda function that allows access to the desired company domain.

Restricting Users to Specific Domains in AWS Cognito | Addend Analytics-1

Step 2. Assuming you have already created the Cognito User Pool, add a lambda trigger in the User Pool properties.

Restricting Users to Specific Domains in AWS Cognito | Addend Analytics-2

Step 3. Select “sign-up” as the trigger type and choose “pre-signup”.

Restricting Users to Specific Domains in AWS Cognito | Addend Analytics-3

Step 4. Provide the Lambda function and add the trigger.

Restricting Users to Specific Domains in AWS Cognito | Addend Analytics-4

Step 5. Test the setup by checking the hosted UI and attempting to use a domain that should not be accessible. You should receive an error if access is restricted..

Restricting Users to Specific Domains in AWS Cognito | Addend Analytics-5

By implementing these steps, you can ensure that only users with email addresses from the specified company domain can access your Cognito user pool, providing an added layer of security and control.

Share :