Skip to content

Migrate users from Auth0 with their password hashes

Move users from Auth0 to Ostiary with a dry run first. Imported bcrypt hashes keep working and become scrypt at sign-in, with no password reset.

Published on 7 min read

The hardest part of leaving Auth0 is not your code, it is your users. Every account has to move, and asking thousands of people to reset their password is the kind of friction that keeps teams on a platform they would rather leave. Ostiary imports an Auth0 user export, with the optional password hash export, from its admin console. A dry run shows what will happen before anything is written, and imported bcrypt passwords keep working: people sign in with the password they already have.

This guide walks through the migration, what moves and what doesn't, and the rules that keep an import safe. If you are still deciding whether to self-host, start with Ostiary as a self-hosted Auth0 alternative.

What moves, and what doesn't

The import creates one Ostiary account per user. From an Auth0 export it keeps:

  • the email address (required, lowercased) and whether it is verified;
  • the name (else given_name and family_name, else nickname), the username and the picture when it is an https:// URL;
  • the creation date;
  • blocked: true, imported as a banned account;
  • the password, when you have its bcrypt hash.

Some things stay behind, by design:

  • Social and enterprise identities. Users sign in with Google, GitHub or their company's single sign-on again. A social sign-in joins the imported account when the provider reports the same verified email and the account's email is verified, except for admins and accounts with two-factor authentication.
  • MFA enrolments and passkeys. Users set them up again from their account.
  • Auth0's user_id. Imported users get a new Ostiary ID, which becomes the sub of their tokens.
  • Metadata and the rest: app_metadata, user_metadata, Auth0 roles and permissions, organizations, sessions and refresh tokens. Every imported user joins the Public organization, like any new account.

Step 1: export your users from Auth0

Auth0 exports users with a job, from the Management API or the User Import / Export extension. With the Management API and a token that has read:users, the bulk user export looks like this:

curl -X POST "https://YOUR_TENANT.auth0.com/api/v2/jobs/users-exports" \
  -H "Authorization: Bearer $AUTH0_TOKEN" -H "Content-Type: application/json" \
  -d '{
    "format": "json",
    "fields": [
      {"name": "user_id"}, {"name": "email"}, {"name": "email_verified"},
      {"name": "name"}, {"name": "given_name"}, {"name": "family_name"}, {"name": "nickname"},
      {"name": "username"}, {"name": "picture"}, {"name": "created_at"}, {"name": "blocked"}
    ]
  }'

Poll GET /api/v2/jobs/{id} until the job is completed, download the file at its location and unzip it. It holds one JSON object per line; the extension's JSON array works too.

Step 2: get the password hashes (optional)

Auth0 never puts password hashes in a user export. You request them through a support case, and they arrive encrypted with a PGP key you provide. Once decrypted, the file has one JSON object per line, with the user's _id, email and passwordHash.

Ostiary matches each hash to a user by ID (_id is the part of Auth0's user_id after auth0|), then by email. If one address appears twice with two different hashes, for example across two Auth0 database connections, it gets no hash rather than a guess.

Treat that file like a password database: anyone holding it can try to crack the passwords offline. Delete it once the import is done.

Without the hashes, the migration still works. Imported users sign in with a code sent by email, or use Forgot password to set a password on their account.

Step 3: dry run, then import

In the admin console, open Users > Import users, choose Auth0 user export (JSON), then the user file and, if you have it, the password hash export.

The dry run reads the whole file and checks it against the accounts already in Ostiary, without writing anything. It counts:

  • the users it will create;
  • the users it will skip: an address that already has an account or, with EMAIL_DEDUP, one that reaches the same inbox (john.doe+x@gmail.com and johndoe@gmail.com);
  • the invalid rows, with the reason for each of the first 50.

Import then parses the files again and refuses to run if they differ from the ones the dry run checked (it compares their SHA-256). Accounts are written 500 per database transaction, with their password and their Public organization membership. An import takes up to 10 MB of files and 50,000 users; split a larger export into several files and import them one after the other, since users already imported are skipped.

Not on Auth0? The same page imports a CSV file with the columns email, name, username, emailVerified, role and passwordHash:

email,name,username,emailVerified,role,passwordHash
jane@example.com,Jane Doe,jane.doe,true,user,$2b$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy
bob@example.com,Bob,,false,,

Any other column refuses the whole file, so a password column with plain-text passwords can never slip through.

How bcrypt passwords keep working

The hashes in Auth0's export are bcrypt hashes. Ostiary hashes new passwords with scrypt, Better Auth's default, and the import keeps the bcrypt hash as it is. Only bcrypt is accepted ($2a$, $2b$ or $2y$, with a cost from 4 to 14); a row with MD5, SHA, Argon2, PBKDF2 or a plain password is refused in the dry run, with its own reason.

At sign-in, a bcrypt hash is checked with bcrypt. Once the password matches, Ostiary hashes it again with scrypt and replaces the stored hash. The update only applies if the stored hash is still the old one, so two sign-ins at the same moment do no harm, and if the upgrade fails the sign-in still succeeds and the next one tries again. The password is only used within that sign-in request. Over time, the bcrypt hashes disappear as people sign in.

The safety rules

An import touches every account at once, so it is deliberately conservative:

  • Existing accounts are never changed. An address that already has an account is skipped, and so is one created between the dry run and the import.
  • No email is sent. No verification, welcome or reset email. Users with an unverified address verify it at their first password sign-in, as usual.
  • No implicit admins. An Auth0 import always creates plain users. A CSV can create admins only when Allow the admin role is ticked, and ADMIN_EMAILS never promotes an account at import.
  • One audit entry per import (user.import), with the file name, its SHA-256, the counts and the addresses of any admins created.
  • Imports are not sign-ups. They don't appear in the sign-up activity and send no user.created webhooks, so your apps are not flooded with events.

After the import: your apps

Your apps switch from Auth0 to Ostiary the way they would switch between any two OpenID Connect providers: a new issuer URL, client ID and secret in the OIDC library they already use. The Connect an app guide has the details.

Two things deserve attention:

  • The sub changes. Apps that store Auth0's sub should match their users again by email at first sign-in.
  • Claims added by Auth0 Actions. If an Action adds claims to your tokens, declare them in Ostiary instead: Applications, the row's menu, Token claims. Each claim is a fixed value or a user attribute from a fixed list (such as the role, the username, the active organization and its role, the user's organizations), in the ID token, the access token or UserInfo. No scripts run, reserved claims such as sub or email are refused, and every change is in the audit log.

To check the result, the Users page has an Export CSV button that downloads the list with the page's search and filters, without password hashes or secrets. The audit log exports the same way.

Try it first

The live demo at demo.ostiary.dev lists two example accounts on its sign-in page: a regular user, and a read-only admin for the admin console, where you can look around everything an admin sees but change nothing. The demo resets every night. When you are ready, deploy Ostiary on Vercel with Neon Postgres, import a small CSV, sign in with an imported account, then run the real export. The full guide is Import users, and the comparison table on the home page sums up what you gain and what you give up by leaving a hosted platform.

Related articles

How Ostiary tells your apps when users change: user and membership webhook events, Standard Webhooks signatures, retries, and a receiver to copy.
How Ostiary handles passkeys: WebAuthn sign-in on your own domain, why the RP ID decides where they work, and the guards around adding one to an account.
Ostiary is an open-source Auth0 alternative you host yourself, built on Better Auth: an OpenID Connect provider, passkeys, SSO and an admin console.