allow instance-wide custom salt for login

This commit is contained in:
ansuz
2017-05-05 09:10:31 +02:00
parent d923fd1b76
commit 3e118c6a38
2 changed files with 20 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
define([
'/customize/application_config.js',
'/bower_components/scrypt-async/scrypt-async.min.js',
], function () {
], function (AppConfig) {
var Cred = {};
var Scrypt = window.scrypt;
@@ -20,9 +21,14 @@ define([
return isString(a) && isString(b) && a === b;
};
Cred.customSalt = function () {
return typeof(AppConfig.loginSalt) === 'string'?
AppConfig.loginSalt: '';
};
Cred.deriveFromPassphrase = function (username, password, len, cb) {
Scrypt(password,
username,
username + Cred.customSalt(), // salt
8, // memoryCost (n)
1024, // block size parameter (r)
len || 128, // dkLen