Using auth:import where PasswordHash = md5( secretKey + PlainTextPassword)
Is this format supported ? It seems common on some legacy CMS. In user json I put "password": base64 encoded hash "salt": base64 encoded secret key where encoded hash = = md5( secretKey + Pass). The secret key is the same for all users. In CLI I entered : firebase auth:import users.json --hash-algo=MD5 rounds=0
Also tried without salt and with CLI command : firebase auth:import users.json --hash-algo=MD5 rounds=0 --hash-key=secretKey
In both cases the user was created but it was impossible to login. (error Invalid password)
Sorry for the late response. MD5 doesn't require hash-key so specifying hash key won't work. I think put secret key at salt field should work. Could you provide a sample test user so that I can look into it?
For MD5, the user.json file should have "passwordHash" and "salt" specified like so:
{
"users": [
{
"localId": "uid1",
"email": "[email protected]",
"emailVerified": true,
"displayName": "Test",
"passwordHash": "MjBmN2VjNzI0ZTY2MWJhZDEzMzM4MmQwZDUzNGIyZjc=",
"salt": "cXdlcnR5"
}
]}
Where you generate the salt like so:
var salt = 'qwerty';
var saltBase64 = new Buffer(salt).toString('base64'); //cXdlcnR5
and the Base64 encoded hash like so:
var hash = crypto.createHash('md5').update(salt+users[i].password).digest('hex');
var base64Hash = new Buffer(hash).toString('base64');
You can then import it using:
firebase auth:import users.json --hash-algo=MD5 --rounds=0
Note:
- The md5 hash object is of the form salt+password
- You need to digest the crypto hash to hex, before setting it to base64.
A complete example of how to upload is here
@kmcnellis tried it exactly as you've described, does not work (anymore?). Did something change?
What error are you getting?
Sorry for not adding this info. When I successfully imported the users like you showed (and that works), I try to login with email and the plain password, and I'll get a "users password is not correct or user has no password" error.
Hm. Still working fine for me. Did you try running the gist?
@RSSfeed @misterfresh did you try the gist? Please reopen and provide a sample test user if this is still an issue.