如何在Firebase中的默认auth:export之后为auth:import设置hash-key选项? [英] How to set hash-key option for auth:import after default auth:export in firebase?

查看:65
本文介绍了如何在Firebase中的默认auth:export之后为auth:import设置hash-key选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的用户已经在CLI中导出了

I've got my users exported the in CLI:

firebase auth:export my_users.json

导出的文件中的密码应使用SCRYPT进行哈希处理,因为文档指出:

The passwords in the exported file should be hashed with SCRYPT, because as the documentation states:

auth:export命令仅导出使用scrypt算法散列的密码,该密码由Firebase后端使用.使用其他算法散列密码的帐户记录将使用空的passwordHash和salt字段导出.从文件中导入用户记录后,项目可能会使用其他算法对密码进行散列处理,因为只有当导入的用户首次登录时,密码才会使用scrypt重新加密

auth:export command only exports passwords hashed using the scrypt algorithm, which is used by the Firebase backend. Account records with passwords hashed using other algorithms are exported with empty passwordHash and salt fields. Projects might have passwords hashed with other algorithms after importing user records from a file, since passwords are only re-hashed with scrypt when an imported user signs in for the first time

我的哈希键和盐字段在结果中不为空. 另外,我知道我所有的用户都至少登录了一次.

My hash-key and salt fields are not empty in the result. Also, I know that all my users signed in at least once.

现在,当我尝试导入my_users.json时:

Now, when I try to import my_users.json:

firebase auth:import --hash-algo=SCRYPT --rounds=1 my_users.json

我收到以下错误:

Must provide hash key(base64 encoded) for hash algorithm SCRYPT

但是,由于auth:export命令没有任何参数,我应该将--hash-key设置为什么? ...

But what should I set --hash-key to, since the auth:export command did not take any parameters? ...

预先感谢

推荐答案

因此,您现在可以从Firebase控制台GUI获取哈希键和盐信息. 由于某种原因,我不得不在chrome中进入隐身模式(firebase支持建议这样做).

So you can now get the hash key and the salt info from the firebase console GUI. I had to enter incognito mode in chrome for some reason (firebase support suggested this).

然后我可以在隐身浏览器中登录我的Firebase控制台.

I could then log into my firebase console in the incognito browser.

(请注意,您需要使用要复制用户的Firebase实例 来自,而不是您要将用户复制到的用户)

(Note that you need to use the firebase instance that you are copying users from, not the one that you are copying users to)

您单击身份验证->用户 然后单击重新加载按钮旁边的三个垂直点,将显示一个弹出菜单,其中包含一个菜单项:密码哈希参数".

You click on Authentication -> Users and then click on the three vertical dots next to the reload button and a popup menu will show up with a single menu item: "Password hash parameters".

点击此菜单项,然后执行 firebase auth:import命令将显示. 这是我看到的:

Click on this menu item and all of the settings you need for doing the firebase auth:import command will show up. Here's what I see:

hash_config {
  algorithm: SCRYPT,
  base64_signer_key: <long string of random characters>,
  base64_salt_separator: <short string of random characters>,
  rounds: 8,
  mem_cost: 14,
}

然后我可以成功执行命令

I can then do the command successfully

firebase auth:import ./users.json --hash-algo=scrypt --rounds=8 --mem-cost=14 --hash-key=<long string of random characters> --salt-separator=<short string of random characters>

这篇关于如何在Firebase中的默认auth:export之后为auth:import设置hash-key选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆