代码之家  ›  专栏  ›  技术社区  ›  ezmegy

在firebase中默认的auth:export之后,如何为auth:import设置哈希键选项?

  •  21
  • ezmegy  · 技术社区  · 9 年前

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

    firebase auth:export my_users.json
    

    导出文件中的密码应使用SCRYPT散列,因为正如文档所述:

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

    此外,我知道我的所有用户至少登录一次。

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

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

    我得到以下错误:

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

    提前感谢

    2 回复  |  直到 9 年前
        1
  •  30
  •   Geoffrey Wall    8 年前

    因此,您现在可以从firebase控制台GUI获得哈希键和salt信息。

    然后,我可以在匿名浏览器中登录firebase控制台。

    (请注意,您需要使用正在复制用户的firebase实例

    然后单击重新加载按钮旁边的三个垂直点,弹出菜单将显示一个菜单项:“密码哈希参数”。

    password hash parameters

    单击此菜单项和执行操作所需的所有设置

    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,
    }
    

    然后我可以成功地执行命令

    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>
    
        2
  •  0
  •   Karri Rasinmäki    7 年前

    参考Firebase文档-“Firebase身份验证密码哈希”: https://firebaseopensource.com/projects/firebase/scrypt/

    查找密码哈希参数

    Firebase为每个Firebase项目生成唯一的密码哈希参数。要访问这些参数,请导航到Firebase控制台中“身份验证”部分的“用户”选项卡,并从用户表右上角的下拉列表中选择“密码哈希参数”。

    their answer

    推荐文章