Okta

Octa

Introduction

One of the challenges when migrating an application's authentication infrastructure to Auth0 is migrating user information from the existing user database to Auth0.

Auth0 provides the following two user import functions, and this time we will introduce the procedure for "batch import".

  • Batch import: Migration using a JSON file that defines user information
  • Automatic migration: Automatically migrate user information from the existing user database when the user logs in via Auth0

In bulk import, define user information extracted from an existing user database etc. as a JSON file and import it to the user database in Auth0. Even if the existing user database stores a password using a hash algorithm compatible with Auth0, users can be migrated without requiring the user to reset their password.

premise

The operation examples on this page are for Auth0-linked web applications.
In addition, the information regarding functions and settings described on this page is current as of November 2022.

Setting overview

The user migration procedure by batch import is as follows.

1. Create a JSON file for import
Describe the user information to be registered according to the format specified by Auth0
2. Import processing of the created JSON file
  • Importing with the Auth0 User Import/Export Extension
  • Import via Auth0 Management API

Limitations

Auth0's bulk import can handle JSON files no larger than 500KB. If it exceeds 500KB, you need to split the JSON file.
https://auth0.com/docs/manage-users/user-migration/bulk-user-imports#create-users-json-file

Setting Example

1. Create JSON file for user import

Write the user information to be registered according to the format specified by Auth0.
Please check the URL below for field names such as email addresses and passwords, hash algorithms supported by Auth0, etc.
Custom password hash / Bulk User Import Database Schema and Examples - Auth0 docs

JSON file creation example (password: hashed by sha256, with salt)

[
 {
   "email": "test.user2@example.com",
   "email_verified": true,
   "blocked": false,
   "custom_password_hash": {
    "algorithm": "sha256",
      "hash": {
        "value": "fe956a8026cf49df7b507dde94e45408dca812f4fa63bbfd1a099b403110e832",
        "encoding": "hex"
      },
      "salt": {
        "value": "abc123",
        "position": "prefix"
      }
  }
 }
]
2. Import processing of the created JSON file
  • Importing with the Auth0 User Import/Export Extension
Ⅰ. Install [User Import/Export] from [Extensions] > [All Extensions] on the Auth0 management screen
Install [User Import/Export] from [Extensions] > [All Extensions] on the Auth0 management screen
Ⅱ. Click the installed [ User Import / Export ] Extension and select the database connection that stores user information in [ Please select a database connection ]
Click the installed [User Import / Export] Extension and select the database connection that stores user information in [Please select a database connection]
Ⅲ. Select the JSON file to be imported and click [ START IMPORTING USERS ] to start importing
Select the JSON file to be imported and click [ START IMPORTING USERS ] to start importing
Ⅳ. Confirm that [Import Status] is displayed as [Completed] and the import is completed.
Confirm that [Import Status] is displayed as [Completed] and the import is completed
Ⅴ. Click [Report] to check whether the import job was successful and whether any errors occurred.
Click [Report] and check if the import job was successful and if any errors occurred.
Ⅵ. After completing the import job, confirm that a completion email has been sent from Auth0
After the import job is completed, confirm that a completion email has been sent from Auth0
Ⅶ. Confirm that the imported user has been added to the specified database connection from [User Management] > [Users] on the Auth0 management screen.
Confirm that the imported user has been added to the specified database connection from [User Management] > [Users] on the Auth0 management screen.
  • Import via Auth0 Management API

There are various ways to execute the API, but the procedure described on this page is performed from the Auth0 Management API Explorer. As a preparation, the following two items are required.

Ⅰ. On the Auth0 Management API Explorer, click [Jobs] > [create import users job]
On the Auth0 Management API Explorer, click Jobs > create import users job
Ⅱ. Enter each parameter value and click [Try]
  • users: Specify the JSON file to import
  • connection_id: Specify the database connection ID of the import destination
  • upsert: Specify "true" to update information for users that exist in the import destination database connection
  • send_completion_email: Specify whether to send a completion email after the import job is completed
Enter each parameter value and click [Try]
Ⅲ. Confirm that [RESPONSE CODE] is displayed as 202 and the import was successful
Confirm that the [RESPONSE CODE] is displayed as 202 and the import was successful
Ⅳ. After completing the import job, confirm that a completion email has been sent from Auth0
After the import job is completed, confirm that a completion email has been sent from Auth0
Ⅴ. Confirm that the imported user has been added to the specified database connection from [User Management] > [Users] on the Auth0 management screen
Confirm that the imported user has been added to the specified database connection from [User Management] > [Users] on the Auth0 management screen.

Supplementary matter

User import job submission and import job completion can also be confirmed from the Auth0 log.

  • Import job submission log
Import job submission log
  • Import job completion log
Import job completion log

Login confirmation example: Login with user information before migration

1. Perform login operation on the web application screen linked with Auth0 and transition to the login screen provided by Auth0
2. Log in with user information before migration
Login with user information before migration
Login with user information before migration
3. Confirm that you were able to log in to the web application with the user information before migration

in conclusion

When migrating users using bulk import, you can easily import user data using a JSON file that defines user information, and if the hash algorithm is supported, there is no need to reset passwords when migrating users. This feature can also be used in the free Auth0 trial environment, so please try it out.
In addition to the bulk import introduced this time, Auth0 also provides a migration method called automatic migration. If you are interested in user migration achieved with Auth0, please contact us.

reference

Inquiry/Document request

In charge of Macnica Okta Co., Ltd.

Mon-Fri 8:45-17:30