sha-512 hash passwords longer than 72 bytes (#4331)
* sha-512 hash passwords longer than 72 bytes * rename compress_hashing to go conventions * add api test for long passwords * fix typo * chore(test): add unit test for password hashing --------- Co-authored-by: Gabe Kangas <gabek@real-ity.com>
This commit is contained in:
co-authored by
Gabe Kangas
parent
4e0becc2e0
commit
f30b80d473
@@ -1,5 +1,6 @@
|
||||
var request = require('supertest');
|
||||
var bcrypt = require('bcrypt');
|
||||
var shajs = require("sha.js");
|
||||
|
||||
const sendAdminRequest = require('./lib/admin').sendAdminRequest;
|
||||
const failAdminRequest = require('./lib/admin').failAdminRequest;
|
||||
@@ -356,6 +357,35 @@ test('reset admin password', async () => {
|
||||
);
|
||||
});
|
||||
|
||||
let newAdminPasswordLong = randomString(80);
|
||||
|
||||
test('change admin password >72 bytes', async () => {
|
||||
await sendAdminRequest('config/adminpass', newAdminPasswordLong);
|
||||
});
|
||||
|
||||
test('verify admin password change (>72 bytes)', async () => {
|
||||
const res = await getAdminResponse(
|
||||
'serverconfig',
|
||||
(adminPassword = newAdminPasswordLong)
|
||||
);
|
||||
|
||||
bcrypt.compare(
|
||||
shajs('SHA512').update(newAdminPasswordLong).digest(),
|
||||
res.body.adminPassword,
|
||||
function (err, result) {
|
||||
expect(result).toBe(true);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test('reset admin password (>72)', async () => {
|
||||
await sendAdminRequest(
|
||||
'config/adminpass',
|
||||
defaultAdminPassword,
|
||||
(adminPassword = newAdminPasswordLong)
|
||||
);
|
||||
});
|
||||
|
||||
test('set override websocket host', async () => {
|
||||
await sendAdminRequest('config/sockethostoverride', overriddenWebsocketHost);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user