]> git.proxmox.com Git - proxmox-perl-rs.git/commitdiff
pve: TfaConfig: add_totp_entry, add_yubico_entry
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 10 Nov 2021 08:51:16 +0000 (09:51 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 10 Nov 2021 08:53:18 +0000 (09:53 +0100)
fast path to add those two from the old user.cfg

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
pve-rs/src/tfa/mod.rs

index 56e63f2615ff80858bffc0485c8932305a1bd8c8..df192b4ca0e6e5c6f25f57d560b522a46bf8ece5 100644 (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,