You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何向Firebase Authentication导入含多属性的用户

Migrating SQL User Data to Firebase Authentication: Key Questions About Importing Attributes & Password Hashes

Background

I'm migrating a large SQL database to Firebase, having converted the SQL data to JSON for import. However, I'm running into issues with importing the user table into Firebase Authentication. My user table's JSON structure looks like this:

"members": [ 
  { 
    "memb_num": "38803", 
    "memb_email": "****@gmail.com", 
    "memb_firstName": "**** ", 
    "memb_lastName": "****", 
    "memb_company": "*****", 
    "memb_street1": "***** Road", 
    "memb_street2": "", 
    "memb_city": "Duarte", 
    "memb_stateNum": "5", 
    "memb_zip": "91010", 
    "memb_country": "United States", 
    "memb_phone": "619-925-0051", 
    "memb_passwd": "5b387bd93ec6ae3f", 
    "memb_passhint": "", 
    "memb_passTemp": "none", 
    "memb_communicate": "Receive E-mails", 
    "memb_boxNum": "5417", 
    "memb_boxSize": "large", 
    "memb_acctType": "PLUS", 
    "memb_24access": "No", 
    "memb_payDue": "0000-00-00", 
    "memb_termLength": "12", 
    "memb_forms": "received", 
    "memb_newMailNotify": "1", 
    "memb_acctClose": "2019-02-02", 
    "memb_added": "2016-02-02", 
    "memb_lastOn": "2018-02-07 14:52:13", 
    "memb_access": "customer", 
    "isTestAccount": "No" 
  } 
]

Technical Questions

  1. Does Firebase Authentication support importing all the above attributes, or do I only need to keep email, password, and UUID? Since there are over 30,000 users, I want the simplest possible solution.
  2. Will the password hash exported from the SQL database work when imported into Firebase Authentication?

Answers

Let's break down your questions one by one to keep things clear for your large-scale migration:

1. Which attributes can/should you import into Firebase Authentication?

Firebase Authentication only stores core identity-related fields for user records. When doing a bulk import, the required/allowed fields are limited to:

  • email (required for password-based auth)
  • passwordHash (or plaintext password, but never use plaintext for bulk imports)
  • localId (optional: your custom UID, like your memb_num; if omitted, Firebase generates one automatically)
  • A few other identity-specific fields (like emailVerified, disabled)

All the extra attributes you have—first name, address, company, account type, etc.—cannot be directly imported into Firebase Auth. Instead, you should store these in Firebase Firestore or Realtime Database, linked to the user's Firebase Auth UID (either your custom memb_num or the auto-generated one).

For simplicity with 30k+ users:

  • First, do a bulk import to Firebase Auth with just email, passwordHash, and localId (using memb_num as the UID makes it easy to link later).
  • Then, import the full member JSON into Firestore/RTDB, using memb_num as the document ID or key. This way, you can always fetch the full user profile by looking up the UID from Auth in the database.

This approach is aligned with Firebase's architecture and keeps your migration steps as straightforward as possible.

2. Will your existing password hash work in Firebase Auth?

It depends on what hash algorithm was used to generate 5b387bd93ec6ae3f. That string looks like a 32-character hex value, which is typical of an MD5 hash (though it could be another algorithm with similar output length).

Firebase Auth supports importing password hashes from several common algorithms (MD5, bcrypt, scrypt, PBKDF2, etc.), but you need to explicitly declare the algorithm and any required parameters (like salt, iteration counts) in your import JSON.

For example, if your hash is MD5, your import entry should look like this:

{
  "localId": "38803",
  "email": "****@gmail.com",
  "passwordHash": "5b387bd93ec6ae3f",
  "passwordHashAlgorithm": "MD5"
}

⚠️ Important: MD5 is a weak, insecure hash algorithm. While Firebase allows importing it, you should plan to prompt users to reset their passwords after migration so Firebase can rehash their passwords using its default secure scrypt algorithm.

If your hash uses a different algorithm (like bcrypt), you'll need to include additional parameters. For example, bcrypt requires specifying the cost factor. Just map your algorithm's parameters to Firebase's required fields in the import JSON to make it work.


内容的提问来源于stack exchange,提问作者Goeken

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 10:03:34