-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit adds support for YubiKey auth. A pinentry prompt asks the user to touch the Yubikey, which causes it to produce input (like a keyboard). That can then be sent to the Bitwarden API where it can ID the YubiKey and validate the request. Fixes: doy#7 Signed-off-by: Dave Tucker <[email protected]>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -172,8 +172,36 @@ pub async fn login( | |||
) | ||||
.await?; | ||||
break; | ||||
} else { | ||||
return Err(anyhow::anyhow!("TODO")); | ||||
} else if providers.contains( | ||||
This comment has been minimized.
Sorry, something went wrong. |
||||
&rbw::api::TwoFactorProviderType::Yubikey, | ||||
){ | ||||
let ( | ||||
access_token, | ||||
refresh_token, | ||||
iterations, | ||||
protected_key, | ||||
) = yubikey_auth( | ||||
tty, | ||||
&email, | ||||
password.clone(), | ||||
) | ||||
.await?; | ||||
login_success( | ||||
sock, | ||||
state, | ||||
access_token, | ||||
refresh_token, | ||||
iterations, | ||||
protected_key, | ||||
password, | ||||
db, | ||||
email, | ||||
) | ||||
.await?; | ||||
break; | ||||
} | ||||
else { | ||||
return Err(anyhow::anyhow!("no supported 2fa method found in {:?}", providers)); | ||||
} | ||||
} | ||||
Err(rbw::error::Error::IncorrectPassword { message }) => { | ||||
|
@@ -277,6 +305,69 @@ async fn two_factor( | |||
unreachable!() | ||||
} | ||||
|
||||
async fn yubikey_auth( | ||||
This comment has been minimized.
Sorry, something went wrong.
soenkeliebau
|
Err(rbw::error::Error::TwoFactorRequired { .. }) => { |
Just tested this locally and it seems to work fine, thank you very much for this!
There are fairly long delays when logging in, but if feels like this is server side (full disclosure: pure conjecture, without having traced it).