From 41ccaa5048d1e29b5d2b5598e5ff814812abda42 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 10 Nov 2021 09:51:16 +0100 Subject: [PATCH] pve: TfaConfig: add_totp_entry, add_yubico_entry fast path to add those two from the old user.cfg Signed-off-by: Wolfgang Bumiller --- pve-rs/src/tfa/mod.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/pve-rs/src/tfa/mod.rs b/pve-rs/src/tfa/mod.rs index 56e63f2..df192b4 100644 --- a/pve-rs/src/tfa/mod.rs +++ b/pve-rs/src/tfa/mod.rs @@ -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 { + 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,