firebase / firebase/firebase-admin-node

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

Ouverte
#1,222 1 commentaire 0 réactions 1 personne assignée Réclamée par @bojeil-google Voir sur GitHub
api: auth
Langage dominant
TypeScript
Étoiles
1.7k
Forks
419
Merge moyen
3 j 10 h
PR mergées (30 j)
16

Description

#### 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);
});
```

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.