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.

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:

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.

You'll write your database action scripts in JavaScript. The scripts run in a Webtask environment and support JavaScript and select Node.js libraries.

  • There are two different types of custom database scripts:

    1. 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.

    2. 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.

  • The get user script 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
    • MongoDB
    • MySQL
    • Oracle
    • PostgreSQL
    • SQLServer
    • 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 Users Using Your Database has information on updating user profile fields.

Keep reading