pve: TfaConfig: add_totp_entry, add_yubico_entry

fast path to add those two from the old user.cfg

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2021-11-10 09:51:16 +01:00
parent 3e5228dd73
commit 41ccaa5048

View File

@ -357,6 +357,37 @@ mod export {
)
}
/// Add a totp entry without validating it, used for user.cfg keys.
/// Returns the ID.
#[export]
fn add_totp_entry(
#[try_from_ref] this: &Tfa,
userid: &str,
description: String,
totp: String,
) -> Result<String, Error> {
Ok(this
.inner
.lock()
.unwrap()
.add_totp(userid, description, totp.parse()?))
}
/// Add a yubico entry without validating it, used for user.cfg keys.
/// Returns the ID.
#[export]
fn add_yubico_entry(
#[try_from_ref] this: &Tfa,
userid: &str,
description: String,
yubico: String,
) -> String {
this.inner
.lock()
.unwrap()
.add_yubico(userid, description, yubico)
}
#[export]
fn api_update_tfa_entry(
#[try_from_ref] this: &Tfa,