mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-06 12:47:13 +02:00
Don't store hashed versions of backup codes
* Really no point; secret must be in plain-text and only ever used in conjunction with pass/etc. * Better oputil handling
This commit is contained in:
parent
6070bc94e7
commit
2767f3c4e3
3 changed files with 39 additions and 62 deletions
|
@ -373,7 +373,7 @@ function twoFactorAuth(user) {
|
|||
qrType : argv['qr-type'] || 'ascii',
|
||||
};
|
||||
prepareOTP(otpType, otpOpts, (err, otpInfo) => {
|
||||
return callback(err, otpInfo);
|
||||
return callback(err, Object.assign(otpInfo, { otpType }));
|
||||
});
|
||||
},
|
||||
function storeOrDisplayQR(otpInfo, callback) {
|
||||
|
@ -381,20 +381,35 @@ function twoFactorAuth(user) {
|
|||
return callback(null, otpInfo);
|
||||
}
|
||||
|
||||
if('-' === argv.out) {
|
||||
console.info(otpInfo.qr);
|
||||
return callback(null, otpInfo);
|
||||
}
|
||||
|
||||
fs.writeFile(argv.out, otpInfo.qr, 'utf8', err => {
|
||||
return callback(err, otpInfo);
|
||||
});
|
||||
},
|
||||
function persist(otpInfo, callback) {
|
||||
const props = {
|
||||
[ UserProps.AuthFactor2OTP ] : otpInfo.otpType,
|
||||
[ UserProps.AuthFactor2OTPSecret ] : otpInfo.secret,
|
||||
[ UserProps.AuthFactor2OTPBackupCodes ] : JSON.stringify(otpInfo.backupCodes),
|
||||
};
|
||||
user.persistProperties(props, err => {
|
||||
return callback(err, otpInfo);
|
||||
});
|
||||
}
|
||||
],
|
||||
(err) => {
|
||||
(err, otpInfo) => {
|
||||
if(err) {
|
||||
console.error(err.message);
|
||||
} else {
|
||||
console.info(`OTP enabled for ${user.username}.`);
|
||||
console.info(`Secret: ${otpInfo.secret}`);
|
||||
console.info(`Backup codes: ${otpInfo.backupCodes.join(', ')}`);
|
||||
|
||||
if(!argv.out) {
|
||||
console.info('QR code:');
|
||||
console.info(otpInfo.qr);
|
||||
} else {
|
||||
console.info(`QR code saved to ${argv.out}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue