firebase / firebase-tools

The Firebase Command Line Tools
MIT License
4.02k stars 933 forks source link

customAttributes is not completely preserved when exporting and importing #3319

Closed 1betatsu closed 1 year ago

1betatsu commented 3 years ago

[REQUIRED] Environment info

firebase-tools: 9.10.0

Platform: macOS

[REQUIRED] Test case

Set custom claim {"admin":true} by any SDK or something. Export accounts from firebase by firebase auth:export, and import the exported file by firebase auth:import. Export accounts again, then you will find the customAttributes miss double quotations like {admin:true}.

[REQUIRED] Steps to reproduce

Set Custom Claims by Go SDK

// Set admin privilege on the user corresponding to uid.
claims := map[string]interface{}{"admin": true}
err = client.SetCustomUserClaims(ctx, uid, claims)
if err != nil {
    log.Fatalf("error setting custom claims %v\n", err)
}

Export accounts

firebase auth:export ACCOUNT_FILE

Import the exported file.

firebase auth:import ACCOUNT_FILE \
    --hash-algo=YOURS \
    --hash-key=YOURS \
    --salt-separator=YOURS \
    --rounds=YOURS \
    --mem-cost=YOURS

[REQUIRED] Expected behavior

Custom claims are preserved as {"admin":true}

[REQUIRED] Actual behavior

Double quotations were disappeared as {admin:true}

thomasmburke commented 1 year ago

Just tested this and it appears this behavior is specific to the CSV export, so if you are looking to preserve custom claims for users upon import and export via firebase-tools the JSON file type is a valid workaround as the team looks to fix buggy behavior highlighted here pertaining to CSV file types.