@@ -13,37 +13,105 @@ credentials.
1313
1414If your setup is different, you can use this document as a starting point in defining your own migration procedure.
1515
16- This document takes you through the following steps:
16+ ## Prerequisites
1717
18- - Exporting password hashes of your Auth0 users
19- - Creating a bulk export that contains the complete user data
20- - Importing Auth0 users to Ory using a custom script
18+ Before you begin, ensure you have:
2119
22- ## Export password hashes
20+ - ** Auth0 account** with admin access to export user data
21+ - ** Ory account** and CLI installed
22+ { /* TODO: change this to refer to new migration guide (docs/migrate-to-ory/migrate/create-project.mdx) */ }
23+ - ** Ory project** created - See [ creating a project] ( index.mdx ) for instructions
24+ - ** Required tools** :
25+ - [ jq] ( https://jqlang.org/ ) - Command-line JSON processor
26+ - [ Gzip] ( https://www.gnu.org/software/gzip/ ) - Compression utility
27+ - [ Ory CLI] ( ../guides/cli/01_installation.mdx ) - Ory command-line interface
28+ - ** Time estimate** : 1-2 hours depending on the number of users
2329
24- Because password hashes are considered sensitive information, Auth0 doesn't export them as part of the general export process. To
25- get the password hashes and other password-related information, you must create an Auth0 support ticket.
30+ ## Overview
31+
32+ The migration process consists of three phases:
33+
34+ 1 . ** Prepare your Auth0 data** - Export user data and password hashes
35+ 2 . ** Configure your Ory project** - Set up identity schema for email authentication
36+ 3 . ** Import users to Ory** - Run the migration script to create users in Ory
37+
38+ ---
39+
40+ ## Phase 1: Prepare your Auth0 data
41+
42+ ### 1. Create bulk user export
43+
44+ To create a [ bulk user export] ( https://auth0.com/docs/manage-users/user-migration/bulk-user-exports ) , you need a Management API
45+ Access Token and the ID of your connection. This data is used by the migration script you run to get the user data. You can
46+ inspect the script
47+ [ here] ( https://raw.githubusercontent.com/ory/docs/master/code-examples/migrate-to-ory/0-get-auth0-user-data.sh ) .
48+
49+ #### Get API access token and connection ID
50+
51+ Follow these steps to get the Management API Access Token and connection ID:
52+
53+ 1 . Go to your [ Auth0 dashboard] ( https://manage.auth0.com/# ) and navigate to ** Applications** → ** APIs** .
54+ 2 . Select ** Auth0 Management API** and go to the ** API Explorer** tab. Copy the displayed token.
55+
56+ :::warning Token expiration
57+ The token is valid for 24 hours by default and is configurable.
58+ :::
59+
60+ 3 . Go to ** Authentication** and navigate to ** Database** .
61+ 4 . Click the connection for which you want to export user data and copy its ID.
62+
63+ #### Run export script
64+
65+ The script accounts for all possible metrics you can export in a bulk user export. The bulk user export is a compressed,
66+ newline-delimited JSON file. The process takes some time to complete and the compressed file is downloaded automatically when it's
67+ ready.
68+
69+ Follow these steps to export the user data:
70+
71+ 1 . Export the required environment variables :
72+
73+ ``` shell
74+ export AUTH0_DOMAIN=" your_auth0_domain.auth0.com"
75+ export AUTH0_CONNECTION_ID=" your_auth0_connection_id"
76+ export AUTH0_TOKEN=" your_auth0_management_api_token"
77+ ```
78+
79+ 2 . Run the script:
80+
81+ ``` shell
82+ bash <( curl https://raw.githubusercontent.com/ory/docs/master/code-examples/migrate-to-ory/0-get-auth0-user-data.sh)
83+ ```
84+
85+ This script creates ` AUTH0_USERDATA.json ` in your current directory containing all exported user data.
86+
87+ ### 2. Export password hashes
88+
89+ Exporting password hashes is optional but recommended. Because password hashes are considered sensitive information, Auth0 doesn't export them as part of the general export process. To get the password hashes and other password-related information, you must [ create an Auth0 support ticket] ( #create-auth0-support-ticket ) .
2690
2791If you get your users' password hashes and import them to Ory, users can log in to their accounts using the same credentials they
2892used before the migration. If you can't get users' password hashes, you can still import Auth0 user accounts to Ory and migrate
2993them using a [ Password migration hook] ( ../kratos/manage-identities/25_import-user-accounts-identities.mdx ) .
3094
31- When you export password hashes, none of the involved parties has access to users' plain text passwords.
95+ :::note
96+ Password hash exports are not available for Auth0's Free subscription tier. You'll need a paid Auth0 plan to request this
97+ data.
98+ :::
3299
33- ### Create Auth0 support ticket
100+ #### Create Auth0 support ticket
34101
35- Follow these steps to get the password hashes from Auth0:
102+ Follow these steps to get the password hashes from Auth0. For more information, see the
103+ [ Auth0 documentation on exporting password hashes] ( https://auth0.com/docs/troubleshoot/customer-support/manage-subscriptions/export-data#user-passwords ) .
36104
371051 . Go to your [ Auth0 dashboard] ( https://manage.auth0.com/# ) and select ** Get Support** .
381062 . Navigate to ** Tickets** → ** View All** and select ** Open Ticket** .
391073 . Choose ** I have a question regarding my Auth0 account** and pick the ** I would like to obtain an export of my tenant password
40108 hashes** option.
411094 . Fill in the form and submit the ticket.
42110
43- ### Exported password hashes
111+ #### Download password hashes file
44112
45- When Auth0 processes your request, you can download a compressed JSON file that contains user IDs, password hashes, and related
46- information. To get complete user data, you must create a bulk user export.
113+ When Auth0 processes your request, download the compressed JSON file that contains user IDs, password hashes, and related
114+ information.
47115
48116The file you get has this format:
49117
@@ -52,99 +120,98 @@ The file you get has this format:
52120{"_ID" :{"$oid" :" 60425da93519d90068f82966" },"email_verified" :false ,"email" :" test@example.com" ,"passwordHash" :" $2b$10$CSZ2JarG4XYbGa.JkfpqnO2wrlbfp5eb5LScHSGo9XGeZ.a.Ic54S" ,"password_set_date" :{"$date" :" 2021-03-05T16:34:49.502Z" },"tenant" :" dev-rwsbs6ym" ,"connection" :" Username-Password-Authentication" ,"_tmp_is_unique" :true }
53121```
54122
55- ## Create a bulk user export
123+ ---
56124
57- To create a [ bulk user export] ( https://auth0.com/docs/manage-users/user-migration/bulk-user-exports ) , you need a Management API
58- Access Token and the ID of your connection. This data is used by the migration script you run to get the user data. You inspect
59- the script [ here] ( https://raw.githubusercontent.com/ory/docs/master/code-examples/migrate-to-ory/0-get-auth0-user-data.sh ) .
125+ ## Phase 2: Configure your Ory project
60126
61- ### Get API Access Token and connection ID
127+ ### 1. Set environment variables
62128
63- Follow these steps to get the Management API Access Token and connection ID :
129+ Set your project and workspace IDs as environment variables :
64130
65- 1 . Go to your [ Auth0 dashboard] ( https://manage.auth0.com/# ) and navigate to ** Applications** → ** APIs** .
66- 2 . Select ** Auth0 Management API** and go to the ** API Explorer** tab. Copy the displayed token. The token is valid for 24 hours,
67- repeat the process to generate a new token.
68- 3 . Go to ** Authentication** and navigate to ** Database** .
69- 4 . Click the connection for which you want to export user data and copy its ID.
131+ ``` shell
132+ export ORY_PROJECT_ID=' {your-project-id}'
133+ export ORY_WORKSPACE_ID=' {your-workspace-id}'
134+ ```
70135
71- ### Run the script
136+ :::tip Finding your IDs
72137
73- To create a bulk user export, run the supplied script. To use it, you must install :
138+ If you don't have these values, you can retrieve them :
74139
75- - [ jq ] ( https://stedolan.github.io/jq/download/ )
76- - [ Gzip ] ( https://www.gnu.org/software/gzip/ )
140+ - ** Using the CLI ** : Run ` ory list projects ` to see all your projects and their IDs
141+ - ** Using the Console ** : Go to [ Ory Console ] ( https://console.ory.sh/ ) , select your project, and find the IDs in the project settings
77142
78- The script accounts for all possible metrics you can export in a bulk user export. The bulk user export is a compressed,
79- newline-delimited JSON. The process takes some time to complete and the compressed file is downloaded automatically when it's
80- ready.
143+ :::
81144
82- Follow these steps:
83145
84- 1 . Export the required environment variables :
85146
86- ``` shell
87- export AUTH0_DOMAIN=" $your_auth0_domain .auth0.com"
88- export AUTH0_CONNECTION_ID=" $your_auth0_connection_id "
89- export AUTH0_TOKEN=" $your_auth0_management_api_token "
90- ```
147+ ### 2. Configure identity schema
91148
92- 2 . Run the script:
149+ Before importing users, you need to configure your Ory project's identity schema to match your Auth0 setup. Since Auth0 users authenticate with email and password, configure the identity schema to use the email preset.
93150
94- ``` shell
95- bash <( curl https://raw.githubusercontent.com/ory/docs/master/code-examples/migrate-to-ory/0-get-auth0-user-data.sh)
96- ```
151+ Update your project's identity schema:
152+
153+ ``` shell
154+ ory patch identity-config --project $ORY_PROJECT_ID --workspace $ORY_WORKSPACE_ID \
155+ --replace ' /identity/default_schema_id="preset://email"' \
156+ --replace '/identity/schemas=[{"id":"preset://email","url":"base64://ewogICIkaWQiOiAiaHR0cHM6Ly9zY2hlbWFzLm9yeS5zaC9wcmVzZXRzL2tyYXRvcy9pZGVudGl0eS5lbWFpbC5zY2hlbWEuanNvbiIsCiAgIiRzY2hlbWEiOiAiaHR0cDovL2pzb24tc2NoZW1hLm9yZy9kcmFmdC0wNy9zY2hlbWEjIiwKICAidGl0bGUiOiAiUGVyc29uIiwKICAidHlwZSI6ICJvYmplY3QiLAogICJwcm9wZXJ0aWVzIjogewogICAgInRyYWl0cyI6IHsKICAgICAgInR5cGUiOiAib2JqZWN0IiwKICAgICAgInByb3BlcnRpZXMiOiB7CiAgICAgICAgImVtYWlsIjogewogICAgICAgICAgInR5cGUiOiAic3RyaW5nIiwKICAgICAgICAgICJmb3JtYXQiOiAiZW1haWwiLAogICAgICAgICAgInRpdGxlIjogIkUtTWFpbCIsCiAgICAgICAgICAib3J5LnNoL2tyYXRvcyI6IHsKICAgICAgICAgICAgImNyZWRlbnRpYWxzIjogewogICAgICAgICAgICAgICJwYXNzd29yZCI6IHsKICAgICAgICAgICAgICAgICJpZGVudGlmaWVyIjogdHJ1ZQogICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgIndlYmF1dGhuIjogewogICAgICAgICAgICAgICAgImlkZW50aWZpZXIiOiB0cnVlCiAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAidG90cCI6IHsKICAgICAgICAgICAgICAgICJhY2NvdW50X25hbWUiOiB0cnVlCiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9LAogICAgICAgICAgICAicmVjb3ZlcnkiOiB7CiAgICAgICAgICAgICAgInZpYSI6ICJlbWFpbCIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgInZlcmlmaWNhdGlvbiI6IHsKICAgICAgICAgICAgICAidmlhIjogImVtYWlsIgogICAgICAgICAgICB9CiAgICAgICAgICB9LAogICAgICAgICAgIm1heExlbmd0aCI6IDMyMAogICAgICAgIH0KICAgICAgfSwKICAgICAgInJlcXVpcmVkIjogWwogICAgICAgICJlbWFpbCIKICAgICAgXSwKICAgICAgImFkZGl0aW9uYWxQcm9wZXJ0aWVzIjogZmFsc2UKICAgIH0KICB9Cn0K"}]'
157+ ```
97158
98- ## Import users to Ory
159+ ---
99160
100- To import your Auth0 users to Ory, you must create new users in Ory and associate them with the imported data.
161+ ## Phase 3: Import users to Ory
101162
102- - If you import the Auth0 user data from the bulk user export and you have the password hashes, your users can log in with their
103- emails and passwords.
104- - If you don't have password hashes from Auth0, create new users for the known email addresses and the associated data. In this
105- case, users must create new passwords when they log in to their accounts for the first time. To facilitate this, enable
106- [ account recovery] ( ../kratos/self-service/flows/account-recovery-password-reset ) .
163+ ### 1. Configure environment variables
107164
108- The procedure is performed by running a
109- [ custom script] ( https://raw.githubusercontent.com/ory/docs/master/code-examples/migrate-to-ory/1-create-ory-identities.sh ) . To use
110- it, you must install:
165+ Configure the migration script by exporting the necessary environment variables:
111166
112- - [ jq] ( https://stedolan.github.io/jq/download/ )
113- - [ Gzip] ( https://www.gnu.org/software/gzip/ )
167+ ``` shell
168+ export RESERVE_ONLY=" false" # Set to "true" if you DON'T HAVE Auth0 password hashes.
169+ export AUTH0_USERDATA=" {path-to-the-json-file-with-bulk-user-export-data}"
170+ export AUTH0_PWEXPORT=" {path-to-the-json-file-with-password-hashes}"
171+ ```
114172
115- Follow these steps to import Auth0 users to Ory:
173+ :::info Migration Mode
116174
117- 1 . Create an Ory Network project using Ory CLI:
175+ - Set ` RESERVE_ONLY="false" ` if you have password hashes
176+ - Set ` RESERVE_ONLY="true" ` if you don't have password hashes
177+ :::
118178
119- ``` shell
120- ory create project --name " Ory Docs Auth0 Migration Example"
121- export ORY_PROJECT_ID=' {set to the project ID from output}'
122- ```
179+ ### 2. Run import script
123180
124- 2 . Change the identity schema using Ory CLI :
181+ Execute the migration script to import users :
125182
126- ``` shell
127- ory patch identity-config --project < project-id> --workspace < workspace-id> \
128- --replace ' /identity/default_schema_id="preset://email"' \
129- --replace '/identity/schemas=[{"id":"preset://email","url":"base64://ewogICIkaWQiOiAiaHR0cHM6Ly9zY2hlbWFzLm9yeS5zaC9wcmVzZXRzL2tyYXRvcy9pZGVudGl0eS5lbWFpbC5zY2hlbWEuanNvbiIsCiAgIiRzY2hlbWEiOiAiaHR0cDovL2pzb24tc2NoZW1hLm9yZy9kcmFmdC0wNy9zY2hlbWEjIiwKICAidGl0bGUiOiAiUGVyc29uIiwKICAidHlwZSI6ICJvYmplY3QiLAogICJwcm9wZXJ0aWVzIjogewogICAgInRyYWl0cyI6IHsKICAgICAgInR5cGUiOiAib2JqZWN0IiwKICAgICAgInByb3BlcnRpZXMiOiB7CiAgICAgICAgImVtYWlsIjogewogICAgICAgICAgInR5cGUiOiAic3RyaW5nIiwKICAgICAgICAgICJmb3JtYXQiOiAiZW1haWwiLAogICAgICAgICAgInRpdGxlIjogIkUtTWFpbCIsCiAgICAgICAgICAib3J5LnNoL2tyYXRvcyI6IHsKICAgICAgICAgICAgImNyZWRlbnRpYWxzIjogewogICAgICAgICAgICAgICJwYXNzd29yZCI6IHsKICAgICAgICAgICAgICAgICJpZGVudGlmaWVyIjogdHJ1ZQogICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgIndlYmF1dGhuIjogewogICAgICAgICAgICAgICAgImlkZW50aWZpZXIiOiB0cnVlCiAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAidG90cCI6IHsKICAgICAgICAgICAgICAgICJhY2NvdW50X25hbWUiOiB0cnVlCiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9LAogICAgICAgICAgICAicmVjb3ZlcnkiOiB7CiAgICAgICAgICAgICAgInZpYSI6ICJlbWFpbCIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgInZlcmlmaWNhdGlvbiI6IHsKICAgICAgICAgICAgICAidmlhIjogImVtYWlsIgogICAgICAgICAgICB9CiAgICAgICAgICB9LAogICAgICAgICAgIm1heExlbmd0aCI6IDMyMAogICAgICAgIH0KICAgICAgfSwKICAgICAgInJlcXVpcmVkIjogWwogICAgICAgICJlbWFpbCIKICAgICAgXSwKICAgICAgImFkZGl0aW9uYWxQcm9wZXJ0aWVzIjogZmFsc2UKICAgIH0KICB9Cn0K"}]'
130- ```
183+ ``` shell
184+ bash <( curl https://raw.githubusercontent.com/ory/docs/master/code-examples/migrate-to-ory/1-create-ory-identities.sh)
185+ ```
131186
132- 3 . Export the necessary environment variables :
187+ You can inspect the script
188+ [ here] ( https://raw.githubusercontent.com/ory/docs/master/code-examples/migrate-to-ory/1-create-ory-identities.sh ) .
133189
134- ``` shell
135- export RESERVE_ONLY=" false" # Set to "true" if you DON'T HAVE Auth0 password hashes.
136- export AUTH0_USERDATA=" {path-to-the-json-file-with-bulk-user-export-data}"
137- export AUTH0_PWEXPORT=" {path-to-the-json-file-with-password-hashes}"
138- ```
190+ ---
139191
140- 4 . Run the script to import users:
192+ ## Post-migration steps
141193
142- ``` shell
143- bash <( curl https://raw.githubusercontent.com/ory/docs/master/code-examples/migrate-to-ory/1-create-ory-identities.sh)
144- ```
194+ After the import script completes, follow these steps to verify and finalize the migration:
145195
146- 5 . Check the list of users available in your project to verify if the operation is successful:
196+ 1 . ** Verify the migration ** : Check the list of users available in your project to confirm the import was successful:
147197
148198 ``` shell
149- ory list identities --project < project-id > --workspace < workspace-id >
199+ ory list identities --project $ORY_PROJECT_ID --workspace $ORY_WORKSPACE_ID
150200 ```
201+
202+ 2 . ** Test user login** : Try logging in with a few test accounts to ensure the migration was successful.
203+
204+ 3 . ** Enable account recovery** (if migrating without password hashes):
205+
206+ - Users will need to reset their passwords on first login
207+ - Ensure [ account recovery] ( ../kratos/self-service/flows/account-recovery-password-reset ) is enabled
208+ - Communicate this to your users before migration
209+
210+ 4 . ** Communicate with users** : Inform your users about:
211+
212+ - The migration timeline
213+ - Any actions they need to take (password reset if migrating without password hashes)
214+ - How to get support if they encounter issues
215+
216+ 5 . ** Monitor the migration** : Keep track of user login attempts and any issues that arise during the first few days after
217+ migration.
0 commit comments