Documentation

Migrating from your own database

Import your users table with its password hashes, or let people move one sign-in at a time through your own endpoint.

All documentation

Choose a path

Your situationUse
You can read the hashes, in a format listed belowA bulk import: everyone moves at once and keeps their password
The hashes are in a format not listed, or you cannot read themLazy migration: your code checks the password, once per person
No passwords (social or enterprise sign-in only)A bulk import with identities, or emailed links and codes

Password hash formats

algorithmhash
bcrypt$2a$, $2b$ or $2y$, cost 4 to 15
argon2$argon2id$v=19$m=…,t=…,p=…$salt$hash (also argon2i, argon2d)
pbkdf2$pbkdf2-sha256$i=…$salt$hash (sha1, sha256, sha512), passlib's $pbkdf2-sha256$29000$…, or Django's pbkdf2_sha256$600000$…
aspnet-identityThe PasswordHash column of ASP.NET Core Identity, version 2 or 3
scrypt$scrypt$ln=…,r=…,p=…$salt$hash
firebase-scryptThe account's passwordHash, with salt; the project's parameters go on the upload
sha256-salted, sha512-saltedhex or base64 (hashEncoding), with salt, saltEncoding (utf8, base64, hex) and saltPosition (prefix or suffix)

Costs above the listed limits (bcrypt 15, PBKDF2 1,200,000 iterations, Argon2 64 MiB, scrypt 32 MiB) are refused with hash_cost_too_high, so one sign-in cannot exhaust the service. MD5 and unsalted SHA-1 are not accepted: use lazy migration for those.

Bulk import

  • Create the applications, their roles and organizations (by slug).
  • Write a JSON array, or a CSV with the header below, one row per person.
  • Upload under Auth admin, Import and export, or POST /api/v1/auth/users/imports (multipart: file, onExisting skip, update or fail, applicationId). The answer is a dry-run report; GET …/imports/{id}/errors lists problem rows by number.
  • Start it with POST …/imports/{id}/start. It runs in the background; a job stopped at the account limit continues when started again.
users.json
[{
  "email": "ada@example.com", "emailVerified": true,
  "givenName": "Ada", "familyName": "Lovelace", "phoneNumber": "+31612345678",
  "publicMetadata": { "plan": "pro" }, "privateMetadata": { "crmId": "C-1" },
  "applicationRoles": { "YOUR_CLIENT_ID": ["waiter"] },
  "organizations": [{ "slug": "acme", "roles": ["admin"] }],
  "passwordHash": { "algorithm": "sha256-salted", "hash": "9f86d0…", "salt": "s4lt", "saltPosition": "suffix" }
}]
users.csv header
email,email_verified,given_name,family_name,phone_number,public_metadata,private_metadata,application_roles,organizations,identity_provider,identity_subject,password_hash_algorithm,password_hash,password_hash_encoding,password_salt,password_salt_encoding,password_salt_position

Lazy migration

Switch it on under Auth admin, Import and export, Lazy migration, with your endpoint's HTTPS URL. Save shows a signing secret once. When someone signs in through a registered application with an address Auth does not know, Auth posts the email and password to your endpoint, signed, and waits up to the timeout you set (1 to 10 seconds). Answer 200 with the person to create the account; answer 401 or 404 otherwise. The person's password is then hashed and kept by Auth, and your endpoint is not asked about them again.

endpoint.mjs (Node, Express)
import crypto from 'node:crypto'
import express from 'express'
const app = express()
app.post('/ziqme/verify', express.text({ type: 'application/json' }), async (req, res) => {
  const timestamp = req.get('Ziqme-Migration-Timestamp')
  const expected = 'v1=' + crypto.createHmac('sha256', process.env.ZIQME_MIGRATION_SECRET)
    .update(timestamp + '.' + req.body).digest('hex')
  const given = req.get('Ziqme-Migration-Signature') ?? ''
  const fresh = Math.abs(Date.now() / 1000 - Number(timestamp)) < 300
  if (!fresh || given.length !== expected.length ||
      !crypto.timingSafeEqual(Buffer.from(given), Buffer.from(expected))) return res.sendStatus(401)
  const { email, password } = JSON.parse(req.body)
  const user = await findUserAndCheckPassword(email, password) // your code; never log the password
  if (!user) return res.sendStatus(401)
  res.json({ email: user.email, emailVerified: user.verified, givenName: user.first, familyName: user.last })
})

Your endpoint receives passwords in clear, inside HTTPS. Auth calls HTTPS URLs on public addresses only and follows no redirect. Run the endpoint yourself, check the signature and the timestamp, never log request bodies, and switch lazy migration off once your people have moved.

Leaving

POST /api/v1/auth/users/exports writes everyone in the same format, so the file imports into another workspace or another product. Password hashes are included only on a plan that allows it and with confirmPasswordHashes: true; that export is recorded in the audit log.