Restrict to two specific domains @ Cognito with google login

Viewed 558

I'm using cloudfront triggering a lambda function to authenticate within cognito.

My Cognito is using google integration for login.

I Would like to restrict to two domains: my-company.com and my-company.io

Is this possible?

1 Answers

Yes, its pretty straight forward.

  1. Setup a Cognito Pre-signup Trigger (https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-sign-up.html)
  2. The trigger will call a lambda function with an event object, the event contains the email address of the user trying to sign. So, in the lambda get the event, extract the email address and compare it with your domains. If you want to allow the sign-up return the event. If you want to reject the sign-up, return a string (error message).
Related