auth-api: update to new tfa crate

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2023-05-10 10:43:13 +02:00
parent 39017fa334
commit 4324aea004

View File

@ -202,20 +202,32 @@ fn authenticate_2nd(
#[allow(clippy::let_unit_value)] #[allow(clippy::let_unit_value)]
{ {
use proxmox_tfa::api::TfaResult;
let mut tfa_config_lock = auth_context.tfa_config_write_lock()?; let mut tfa_config_lock = auth_context.tfa_config_write_lock()?;
let (locked_config, tfa_config) = tfa_config_lock.config_mut(); let (locked_config, tfa_config) = tfa_config_lock.config_mut();
if tfa_config let result = tfa_config.verify(
.verify(
locked_config, locked_config,
userid.as_str(), userid.as_str(),
&challenge, &challenge,
response.parse()?, response.parse()?,
None, None,
)? );
.needs_saving()
{ let (success, needs_saving) = match result {
TfaResult::Locked => (false, false),
TfaResult::Failure { needs_saving, .. } => {
// TODO: Implement notifications for totp/tfa limits!
(false, needs_saving)
}
TfaResult::Success { needs_saving } => (true, needs_saving),
};
if needs_saving {
tfa_config_lock.save_config()?; tfa_config_lock.save_config()?;
} }
if !success {
bail!("authentication failed");
}
} }
Ok(AuthResult::CreateTicket) Ok(AuthResult::CreateTicket)