firebase / firebase-admin-go

Firebase Admin Go SDK
Apache License 2.0
1.12k stars 239 forks source link

[AUTH - IMPORT USER ] INVALID_PASSWORD_HASH : OpenBSDBCrypt hash error for verification: not a Bcrypt string #595

Closed asyrawih closed 7 months ago

asyrawih commented 7 months ago

[READ] Step 1: Are you in the right place?

i have try import user using bcrypt but got the message

{
    "error": {
        "code": 400,
        "message": "INVALID_PASSWORD_HASH : OpenBSDBCrypt hash error for verification: not a Bcrypt string",
        "errors": [
            {
                "message": "INVALID_PASSWORD_HASH : OpenBSDBCrypt hash error for verification: not a Bcrypt string",
                "domain": "global",
                "reason": "invalid"
            }
        ]
    }
}

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

by following this code and see ref from firebase cli i have to encode the hashed password with base64 i have check the hashedpassword and compare it with plain password the hash match

Relevant Code:

    hashedPassword := []byte("$2a$08$Fi60ML92l/WR13O2dx9/b.R408cIoIF7pQw8HEDycadI.BSCp7DmO")

    s := base64.StdEncoding.EncodeToString(hashedPassword)
    t.Log(s)

    users := []*auth.UserToImport{
        (&auth.UserToImport{}).
            UID("some-uid").
            Email("asyrawih@gmail.com").
            PasswordHash([]byte(s))}

    b := hash.Bcrypt{}

    uir, err := ClientAuth.ImportUsers(context.Background(), users, auth.WithHash(b))
    if err != nil {
        log.Fatal(err)
    }

    t.Log(uir)

result of this code success for import

test on postman

image

i have test import the user with firebase cli the working password can verify

image
google-oss-bot commented 7 months ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.