Site Search

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
Auth0管理画面の[ Extensions ] > [ All Extensions ]から、[ User Import / Export ]をインストール
Ⅱ. Click the installed [ User Import / Export ] Extension and select the database connection that stores user information in [ Please select a database connection ]
インストールした[ User Import / Export ]Extensionをクリックし、[ Please select a database connection ]でユーザの情報を格納するdatabase connectionを選択
Ⅲ. Select the JSON file to be imported and click [ START IMPORTING USERS ] to start importing
インポート対象のJSONファイルを選択の上、[ START IMPORTING USERS ]をクリックしてインポートを開始
Ⅳ. Confirm that [Import Status] is displayed as [Completed] and the import is completed.
[ Import Status ]が[ Completed ]と表示され、インポートが完了したことを確認
Ⅴ. Click [Report] to check whether the import job was successful and whether any errors occurred.
[ Report ]をクリックし、インポートジョブの成功及びエラー発生有無を確認
Ⅵ. After completing the import job, confirm that a completion email has been sent from Auth0
インポートジョブ完了後、Auth0より完了メールが送付されたことを確認
Ⅶ. Confirm that the imported user has been added to the specified database connection from [User Management] > [Users] on the Auth0 management screen.
Auth0管理画面の [ User Management ] > [ Users ]から、指定したdatabase connectionにインポートしたユーザが追加されたことを確認
  • 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]
Auth0 Management API Explorer上で、[ 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
各パラメータ値を入力し、[ Try ]をクリック
Ⅲ. Confirm that [RESPONSE CODE] is displayed as 202 and the import was successful
[ RESPONSE CODE ]が202と表示され、インポートが成功したことを確認
Ⅳ. After completing the import job, confirm that a completion email has been sent from Auth0
インポートジョブ完了後、Auth0より完了メールが送付されたことを確認
Ⅴ. Confirm that the imported user has been added to the specified database connection from [User Management] > [Users] on the Auth0 management screen
Auth0管理画面の [User Management ] > [ Users ]より、指定したdatabase connectionにインポートしたユーザが追加されたことを確認

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
移行前のユーザ情報でログインを実施
移行前のユーザ情報でログインを実施
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.

Weekdays: 9:00-17:00