This repo contains the files and insturctions required to setup Cognito as a custom database connection with Auth0.
- Create a user pool in aws cognito
- For this user pool create an app client
- This client should have no client secret
- Make sure to check
Enable username password auth for admin APIs for authentication (ALLOW_ADMIN_USER_PASSWORD_AUTH) - Make sure to select
LegacyunderPrevent User Existence Errors
- For this user pool create an app client
- Make a note of the following properties
UserPoolId- ID of the user poolClientID- Client ID of the application created aboveregion- AWS RegionaccessKeyId- Access Key IDsecretAccessKey- Secret Access Key
- Create a database connection
-
Create a custom database connection and choose the name you want to use for it
-
Turn on the toggle
Use my own databaseunder theCustom Databasetab -
Under the database
settingstab turn on toggles forRequires UsernameImport Users to Auth0- This enables migration at login with Cognito
-
Go back to the
Custom Databasetab- Copy contents of
auth0LoginDirect.jsunder theLoginscript - Copy contents of
auth0GetUserDirect.jsunder theGet Userscript
- Copy contents of
-
Make sure you save both the scripts above
-
Remain on the same tab and scroll down to
settings- Set the Confgiuration variables
- accessKeyId : your access key for AWS
- secretAccessKey: your secret key for AWS>
- region : region of aws
- UserPoolId : Id of the User Pool
- ClientId : client id of the app created in cognito
- Set the Confgiuration variables
-
At this point you have everything setup for the connection
-
Enable the connection in Auth0 by enabling this connection on an application
-
Test login and get user scripts
-