Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
fix(authentication): fix auth issue with BSON promoteBuffers: true
Browse files Browse the repository at this point in the history
  • Loading branch information
sebdeckers authored and daprahamian committed May 7, 2019
1 parent 1fa5763 commit bcb87ca
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/auth/scram.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ class ScramSHA extends AuthProvider {
return callback(tmpError, null);
}

const dict = parsePayload(r.payload.value());
const payload = Buffer.isBuffer(r.payload) ? new Binary(r.payload) : r.payload;
const dict = parsePayload(payload.value());
const iterations = parseInt(dict.i, 10);
const salt = dict.s;
const rnonce = dict.r;
Expand All @@ -198,7 +199,7 @@ class ScramSHA extends AuthProvider {

const clientKey = HMAC(cryptoMethod, saltedPassword, 'Client Key');
const storedKey = H(cryptoMethod, clientKey);
const authMessage = [firstBare, r.payload.value().toString('base64'), withoutProof].join(',');
const authMessage = [firstBare, payload.value().toString('base64'), withoutProof].join(',');

const clientSignature = HMAC(cryptoMethod, storedKey, authMessage);
const clientProof = `p=${xor(clientKey, clientSignature)}`;
Expand Down

0 comments on commit bcb87ca

Please sign in to comment.