mdave16
mdave16

Reputation: 186

Migrating from firebase to auth0

I'm trying to convert from firebase into an auth0 db, by converting firebase export data into the auth0 bulk user import format.

I have a user in firebase (under the firebase_export) section, and the firebase hash config itself (hash config below), but I'm not clear on how the base64_signer_key fits in or the salt used in the export.

{
  "firebase_export": {
    "localId": "localId",
    "email": "[email protected]",
    "emailVerified": true,
    "passwordHash": "base64hash",
    "salt": "user_salt",
    "lastSignedInAt": "1649680364736",
    "createdAt": "1649680237223",
    "disabled": false,
    "providerUserInfo": []
  },
  "hash_config": {
    "algorithm": "SCRYPT",
    "base64_signer_key": "base64_signer_key",
    "base64_salt_separator": "base64_salt_separator",
    "rounds": 8,
    "mem_cost": 14
  }
}

I think the schema should look like this, but this is not working. (I log in to auth0 with a known password and it fails, while passing in firebase).

[
  {
    "user_id": $localId,
    "email": $email,
    "email_verified": $emailVerified,
    "custom_password_hash": {
      "algorithm": "scrypt",
      "hash": {
        "value": $passwordHash,
        "encoding": "base64"
      },
      "salt" : {
        "value": base64Decode($salt) + base64Decode($hash_config.base64_salt_separator), 
// based off reading https://github.com/firebase/scrypt
        "encoding":"utf8",
        "position" "suffix", // based off reading https://github.com/firebase/scrypt, uses PBKDF2_SHA256 which places salt as suffix.
      },
      "password" : {
        "encoding":"utf8"
      },
      "keylen": 64,
      "cost": 2**$hash_config.mem_cost,
      "blockSize": $hash_config.rounds,
      "parallelization": 1,
    },
    "blocked": $disabled
  }
]

Upvotes: 0

Views: 985

Answers (1)

mdave16
mdave16

Reputation: 186

Because Firebase uses a custom scrypt rather than the standard implementation, auth0 said it is unable to import users.

Other solutions to try:

  • add a login callback within your code to create/update/delete users in auth0 in an async fashion, to slowly migrate users over.
  • pay auth0 lots of money to run a custom db migration (still slow).
  • migrate all users without password and say that we need all users to reset their password

all of which sound suboptimal

Upvotes: 1

Related Questions