firebase / firebase/firebase-admin-node

Invalid hash rounds for round = 0 and for algorithms PBKDF_SHA1 / PBKDF2_SHA256

Abierto
#1,222 1 comentario 0 reacciones 1 asignado Reclamado por @bojeil-google Ver en GitHub
api: auth
Lenguaje dominante
TypeScript
Estrellas
1.7k
Forks
419
Merge medio
3 d 10 h
PR fusionados (30 d)
16

Descripción

#### Describe your environment

* Operating System version: macOS Big Sur v11.2.3
* Firebase SDK version: 9.6.0
* Firebase Product: auth
* Node.js version: 15.14.0
* NPM version: 7.9.0

### Describe the problem

#### Steps to reproduce:

At function admin.auth().importUsers(), set hash options to "algorithm" PBKDF_SHA1 or PBKDF2_SHA256 and "rounds" equals to 0. Rounds value equals to zero is being considered invalid. Documentation states that values between 0 and 120000 are possible.

Server returning this error:
```
errorInfo: {
code: 'auth/internal-error',
message: 'An internal error has occurred. Raw server response: "{"error":{"code":400,"message":"INVALID_HASH_ROUNDS","errors":[{"message":"INVALID_HASH_ROUNDS","domain":"global","reason":"invalid"}]}}"'
},
codePrefix: 'auth'
```

#### Relevant Code:

```
admin
.auth()
.importUsers(
[
{
uid: 'some-uid',
email: 'user@example.com',
// Must be provided in a byte buffer.
passwordHash: Buffer.from('password-hash'),
// Must be provided in a byte buffer.
passwordSalt: Buffer.from('salt'),
},
],
{
hash: {
algorithm: 'PBKDF2_SHA256',
rounds: 0,
},
}
)
.then((results) => {
results.errors.forEach((indexedError) => {
console.log(`Error importing user ${indexedError.index}`);
});
})
.catch((error) => {
console.log('Error importing users :', error);
});
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.