Authenticate Users Using Your Database
If you have your own user database, you can use it as an identity provider in Auth0 to authenticate users.
Only Enterprise subscription plans include the ability to use a custom database for authentication requests.
For more information refer to Auth0 pricing plans.
In this tutorial, you'll learn how to connect your user database to Auth0 and configure it for use as an identity provider. More specifically, you will:
- Create and configure a custom database connection using the Auth0 dashboard.
- Make sure that your database has the appropriate fields to store user profiles attributes, such as id, nickname, email, and password. See Normalized User Profile for details on Auth0's user profile schema and the expected fields.
- Provide database action scripts to configure the database for use as an identity provider.
Before you begin
Here are some things to know before you begin the process of setting up your database for use as an identity provider.
There are two different types of custom database scripts:
Trickle Migration: Whenever a user logs into Auth0, if the user is not yet in Auth0, the script will check the legacy database to see if the user is there. If they are there, it will migrate the user to Auth0. This script runs when the Import users to Auth0 flag is turned on.
Legacy DB: Auth0 will always call out to the underlying database anytime a user tries to log in, is created, changes their password, verifies their email, or is deleted. Users stay in the legacy database and do not migrate to Auth0.
get userscript is very important. Here are all the places where it is called:
- Change email: to validate availability
- Create user: to validate availability
- Forgot password: to validate
- Change password: to create
Auth0 provides custom script templates for most of the commonly-used databases, including:
- ASP.NET Membership Provider
- Windows Azure SQL Database
- Web services accessed via Basic Auth
Essentially, you can connect to any kind of database or web service with a properly-configured custom script.
Update User Profiles Using Your Database has information on updating user profile fields.
If you are behind a firewall, this feature may require whitelisting of the appropriate Auth0 IP addresses to work properly.