如何在 firebase 默认 auth:export 后为 auth:import 设置散列键选项?
How to set hash-key option for auth:import after default auth:export in firebase?
我已经让我的用户在 CLI 中导出了:
firebase auth:export my_users.json
导出文件中的密码应使用 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_users.json:
firebase auth:import --hash-algo=SCRYPT --rounds=1 my_users.json
我收到以下错误:
Must provide hash key(base64 encoded) for hash algorithm SCRYPT
但是我应该将 --hash-key 设置为什么,因为 auth:export 命令没有带任何参数? ...
提前致谢
现在您可以从 firebase 控制台 GUI 获取散列键和盐信息。
出于某种原因,我不得不在 chrome 中进入隐身模式(firebase 支持建议这样做)。
然后我可以在隐身浏览器中登录我的 firebase 控制台。
(注意需要使用复制用户的firebase实例
来自,而不是您要将用户复制到的那个)
您点击身份验证 -> 用户
然后单击重新加载按钮旁边的三个垂直点,弹出菜单将显示一个菜单项:"Password hash parameters".
单击此菜单项以及执行此操作所需的所有设置
firebase auth:import 命令将出现。
这是我看到的:
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>
参考 Firebase 文档 - "Firebase Authentication Password Hashing":
https://firebaseopensource.com/projects/firebase/scrypt/
Finding the Password Hash Parameters
Firebase generates unique password hash parameters for each Firebase project. To access these parameters, navigate to the 'Users' tab of the 'Authentication' section in the Firebase Console and select 'Password Hash Parameters' from the drop down in the upper-right hand corner of the users table.
不幸的是,似乎没有通过 cli 获取哈希参数的选项。所以,我想 GUI 是唯一的方法(正如 Geoffrey Wall 在 上提到的那样)。
我已经让我的用户在 CLI 中导出了:
firebase auth:export my_users.json
导出文件中的密码应使用 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_users.json:
firebase auth:import --hash-algo=SCRYPT --rounds=1 my_users.json
我收到以下错误:
Must provide hash key(base64 encoded) for hash algorithm SCRYPT
但是我应该将 --hash-key 设置为什么,因为 auth:export 命令没有带任何参数? ...
提前致谢
现在您可以从 firebase 控制台 GUI 获取散列键和盐信息。 出于某种原因,我不得不在 chrome 中进入隐身模式(firebase 支持建议这样做)。
然后我可以在隐身浏览器中登录我的 firebase 控制台。
(注意需要使用复制用户的firebase实例 来自,而不是您要将用户复制到的那个)
您点击身份验证 -> 用户 然后单击重新加载按钮旁边的三个垂直点,弹出菜单将显示一个菜单项:"Password hash parameters".
单击此菜单项以及执行此操作所需的所有设置 firebase auth:import 命令将出现。 这是我看到的:
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>
参考 Firebase 文档 - "Firebase Authentication Password Hashing": https://firebaseopensource.com/projects/firebase/scrypt/
Finding the Password Hash Parameters
Firebase generates unique password hash parameters for each Firebase project. To access these parameters, navigate to the 'Users' tab of the 'Authentication' section in the Firebase Console and select 'Password Hash Parameters' from the drop down in the upper-right hand corner of the users table.
不幸的是,似乎没有通过 cli 获取哈希参数的选项。所以,我想 GUI 是唯一的方法(正如 Geoffrey Wall 在