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
Legacy
underPrevent 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 database
under theCustom Database
tab -
Under the database
settings
tab turn on toggles forRequires Username
Import Users to Auth0
- This enables migration at login with Cognito
-
Go back to the
Custom Database
tab- Copy contents of
auth0LoginDirect.js
under theLogin
script - Copy contents of
auth0GetUserDirect.js
under theGet User
script
- 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
-