Przejdź do treści
Logo Aurabase
aurabaza

Zbiorczy import użytkowników

Importuj do 1000 użytkowników na partię za pomocą starszych skrótów haseł bcrypt lub nowoczesnych Argon2id. Przejrzysta aktualizacja do Argon2id przy następnym logowaniu.

Przewodnik krok po kroku5 min przeczytanePoziom mediator

Źródło angielskie uległo zmianie od czasu tego tłumaczenia. Niektóre informacje mogą być nieaktualne.
Ta strona została przetłumaczona automatycznie. Wersja angielska jest miarodajna.

Importing users from another platform#

When migrating from Supabase, Firebase, Auth0, or a custom authentication database, users expect their existing passwords to keep working without a global password reset.

Aurabase provides a high-throughput bulk import endpoint (POST /v1/auth/admin/users/import) capable of ingesting up to 1,000 users per request. The operation returns an itemized status report so invalid records do not block the rest of the batch.

Supported password hashes and transparent upgrade#

The import endpoint supports the following password hashing algorithms:

AlgorithmIdentifiersBehavior
Argon2id$argon2id$v=19$m=...Verified directly using OWASP parameters.
bcrypt$2a$, $2b$, $2y$Verified on login and transparently re-encoded to Argon2id upon first successful authentication.

If no password_hash is provided for a user, the account is created without a password. The user can authenticate using Magic Links, Email/SMS OTP, or a password reset link.

Bulk import endpoint#

Requires administrator authorization (service_role key).

curl -X POST "$NEXT_PUBLIC_AURABASE_URL/v1/auth/admin/users/import" \
  -H "apikey: $AURABASE_SERVICE_ROLE_KEY" \
  -H "Authorization: Bearer $AURABASE_SERVICE_ROLE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "users": [
      {
        "email": "[email protected]",
        "email_verified": true,
        "password_hash": "$2b$12$e8kPM4QJ8a2x4K7hM0uL.OeQ7f...",
        "name": "Alice Johnson",
        "user_metadata": { "department": "Engineering" }
      },
      {
        "email": "[email protected]",
        "email_verified": false,
        "password_hash": "$argon2id$v=19$m=65536,t=3,p=4$..."
      }
    ]
  }'

Response (200 OK)

The response details the total number of records processed along with an itemized report:

{
  "data": {
    "created": 2,
    "skipped": 0,
    "errors": 0,
    "report": [
      {
        "index": 0,
        "email": "[email protected]",
        "status": "created",
        "id": "e3b0c442-98fc-1c14-9afb-f4c599684824"
      },
      {
        "index": 1,
        "email": "[email protected]",
        "status": "created",
        "id": "7d2b5129-3bdf-48bc-8919-4b684df69921"
      }
    ]
  }
}

If an email already exists in the project, it is marked as skipped rather than raising a fatal error.

TypeScript SDK#

Use authAdmin.importUsers():

import { createClient } from '@aurabase/aurabase-js'

const aura = createClient(process.env.NEXT_PUBLIC_AURABASE_URL!, process.env.AURABASE_SERVICE_ROLE_KEY!)

const usersToImport = [
  {
    email: '[email protected]',
    emailVerified: true,
    passwordHash: '$2b$12$e8kPM4QJ8a2x4...',
    name: 'User One',
    userMetadata: { plan: 'pro' },
  },
  {
    email: '[email protected]',
    emailVerified: false,
    passwordHash: '$argon2id$v=19$m=65536,t=3,p=4$...',
    name: 'User Two',
  },
]

const { data, error } = await aura.authAdmin.importUsers(usersToImport)

if (error) {
  console.error('Import failed:', error.message)
} else {
  console.log(`Import summary: ${data.created} created, ${data.skipped} skipped, ${data.errors} errors`)

  for (const item of data.report) {
    if (item.status === 'error') {
      console.warn(`Row ${item.index} (${item.email}) error: ${item.error}`)
    }
  }
}

Import via Aurabase Studio#

You can also import users directly through the web interface:

  1. Navigate to Authentication › Users in your project dashboard.
  2. Click the Import users button in the top toolbar.
  3. Choose JSON or CSV format. You can click Insert sample to inspect the expected schema.
  4. Paste your data and click Start Import.
  5. Inspect the batch summary and row-by-row status report.
@aurabase/aurabase-js@0.7.5 · aura@0.3.4↗ Zgłoś problem