1
0
Fork 0
mirror of https://github.com/dani-garcia/vaultwarden.git synced 2025-06-11 05:23:53 +00:00

Added option to force 2fa at logins and made some changes to two factor code.

Added newlines to config options to keep them a reasonable length.
This commit is contained in:
Daniel García 2019-03-03 16:09:15 +01:00
parent c6c00729e3
commit 7d2bc9e162
No known key found for this signature in database
GPG key ID: FC8A7D14C3CD543A
4 changed files with 78 additions and 79 deletions

View file

@ -42,21 +42,6 @@ impl TwoFactor {
}
}
pub fn check_totp_code(&self, totp_code: u64) -> bool {
let totp_secret = self.data.as_bytes();
use data_encoding::BASE32;
use oath::{totp_raw_now, HashType};
let decoded_secret = match BASE32.decode(totp_secret) {
Ok(s) => s,
Err(_) => return false,
};
let generated = totp_raw_now(&decoded_secret, 6, 0, 30, &HashType::SHA1);
generated == totp_code
}
pub fn to_json(&self) -> Value {
json!({
"Enabled": self.enabled,