Browse Source
Merge pull request #257 from Step7750/fix-nfc-mobile
Fixes NFC Response for Mobile Yubikey OTP Login
pull/258/head
Daniel García
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
15 additions and
2 deletions
-
src/api/core/two_factor.rs
-
src/api/identity.rs
|
|
@ -507,9 +507,9 @@ struct EnableYubikeyData { |
|
|
|
|
|
|
|
#[derive(Deserialize, Serialize, Debug)] |
|
|
|
#[allow(non_snake_case)] |
|
|
|
struct YubikeyMetadata { |
|
|
|
pub struct YubikeyMetadata { |
|
|
|
Keys: Vec<String>, |
|
|
|
Nfc: bool, |
|
|
|
pub Nfc: bool, |
|
|
|
} |
|
|
|
|
|
|
|
use yubico::Yubico; |
|
|
|
|
|
@ -269,6 +269,19 @@ fn _json_err_twofactor(providers: &[i32], user_uuid: &str, conn: &DbConn) -> Api |
|
|
|
result["TwoFactorProviders2"][provider.to_string()] = Value::Object(map); |
|
|
|
} |
|
|
|
|
|
|
|
Some(TwoFactorType::YubiKey) => { |
|
|
|
let twofactor = match TwoFactor::find_by_user_and_type(user_uuid, TwoFactorType::YubiKey as i32, &conn) { |
|
|
|
Some(tf) => tf, |
|
|
|
None => err!("No YubiKey devices registered"), |
|
|
|
}; |
|
|
|
|
|
|
|
let yubikey_metadata: two_factor::YubikeyMetadata = serde_json::from_str(&twofactor.data).expect("Can't parse Yubikey Metadata"); |
|
|
|
|
|
|
|
let mut map = JsonMap::new(); |
|
|
|
map.insert("Nfc".into(), Value::Bool(yubikey_metadata.Nfc)); |
|
|
|
result["TwoFactorProviders2"][provider.to_string()] = Value::Object(map); |
|
|
|
} |
|
|
|
|
|
|
|
_ => {} |
|
|
|
} |
|
|
|
} |
|
|
|