Adds bcrypt native binding for better login performance (#2549)
* Adds bcrypt native binding for better login performance * Swaps bcrypt-nodejs for bcryptjs as compatible with bcrypt native * Fixes package versions
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-polyfill": "6.13.0",
|
"babel-polyfill": "6.13.0",
|
||||||
"bcrypt-nodejs": "0.0.3",
|
"bcryptjs": "2.3.0",
|
||||||
"body-parser": "1.15.2",
|
"body-parser": "1.15.2",
|
||||||
"commander": "2.9.0",
|
"commander": "2.9.0",
|
||||||
"deepcopy": "0.6.3",
|
"deepcopy": "0.6.3",
|
||||||
@@ -53,6 +53,7 @@
|
|||||||
"babel-preset-es2015": "6.13.2",
|
"babel-preset-es2015": "6.13.2",
|
||||||
"babel-preset-stage-0": "6.5.0",
|
"babel-preset-stage-0": "6.5.0",
|
||||||
"babel-register": "6.11.6",
|
"babel-register": "6.11.6",
|
||||||
|
"bcrypt-nodejs": "0.0.3",
|
||||||
"cross-env": "2.0.0",
|
"cross-env": "2.0.0",
|
||||||
"deep-diff": "0.3.4",
|
"deep-diff": "0.3.4",
|
||||||
"gaze": "1.1.1",
|
"gaze": "1.1.1",
|
||||||
@@ -60,7 +61,7 @@
|
|||||||
"jasmine": "2.4.1",
|
"jasmine": "2.4.1",
|
||||||
"mongodb-runner": "3.3.2",
|
"mongodb-runner": "3.3.2",
|
||||||
"nodemon": "1.10.0",
|
"nodemon": "1.10.0",
|
||||||
"request-promise": "^4.1.1"
|
"request-promise": "4.1.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "npm run build && node bin/dev",
|
"dev": "npm run build && node bin/dev",
|
||||||
@@ -77,5 +78,8 @@
|
|||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"parse-server": "./bin/parse-server"
|
"parse-server": "./bin/parse-server"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"bcrypt": "0.8.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,18 @@ describe('Auth', () => {
|
|||||||
auth.getUserRoles()
|
auth.getUserRoles()
|
||||||
.then((roles) => expect(roles).toEqual([]))
|
.then((roles) => expect(roles).toEqual([]))
|
||||||
.then(() => done());
|
.then(() => done());
|
||||||
})
|
});
|
||||||
|
|
||||||
|
it('should properly handle bcrypt upgrade', (done) => {
|
||||||
|
var bcryptOriginal = require('bcrypt-nodejs');
|
||||||
|
var bcryptNew = require('bcryptjs');
|
||||||
|
bcryptOriginal.hash('my1Long:password', null, null, function(err, res) {
|
||||||
|
bcryptNew.compare('my1Long:password', res, function(err, res) {
|
||||||
|
expect(res).toBeTruthy();
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
// Tools for encrypting and decrypting passwords.
|
// Tools for encrypting and decrypting passwords.
|
||||||
// Basically promise-friendly wrappers for bcrypt.
|
// Basically promise-friendly wrappers for bcrypt.
|
||||||
var bcrypt = require('bcrypt-nodejs');
|
var bcrypt = require('bcryptjs');
|
||||||
|
|
||||||
|
try {
|
||||||
|
bcrypt = require('bcrypt');
|
||||||
|
} catch(e) {}
|
||||||
|
|
||||||
// Returns a promise for a hashed password string.
|
// Returns a promise for a hashed password string.
|
||||||
function hash(password) {
|
function hash(password) {
|
||||||
return new Promise(function(fulfill, reject) {
|
return new Promise(function(fulfill, reject) {
|
||||||
bcrypt.hash(password, null, null, function(err, hashedPassword) {
|
bcrypt.hash(password, 10, function(err, hashedPassword) {
|
||||||
if (err) {
|
if (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user