//! If we add more, it should be moved into a sub module.
use anyhow::Error;
+use hex::FromHex;
-use crate::api2::types::PROXMOX_CONFIG_DIGEST_SCHEMA;
-use proxmox::api::{api, Permission, Router, RpcEnvironment, SubdirMap};
-use proxmox::api::schema::Updatable;
-use proxmox::list_subdirs_api_method;
+use proxmox_router::{Router, RpcEnvironment, Permission, SubdirMap};
+use proxmox_schema::api;
+use proxmox_router::list_subdirs_api_method;
+
+use pbs_api_types::PROXMOX_CONFIG_DIGEST_SCHEMA;
use crate::config::tfa::{self, WebauthnConfig, WebauthnConfigUpdater};
Some(c) => c,
None => return Ok(None),
};
- rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+ rpcenv["digest"] = hex::encode(&digest).into();
Ok(Some(config))
}
if let Some(wa) = &mut tfa.webauthn {
if let Some(ref digest) = digest {
- let digest = proxmox::tools::hex_to_digest(digest)?;
- crate::tools::detect_modified_configuration_file(&digest, &wa.digest()?)?;
+ let digest = <[u8; 32]>::from_hex(digest)?;
+ crate::tools::detect_modified_configuration_file(
+ &digest,
+ &crate::config::tfa::webauthn_config_digest(&wa)?,
+ )?;
}
- wa.update_from::<&str>(webauthn, &[])?;
+ if let Some(ref rp) = webauthn.rp { wa.rp = rp.clone(); }
+ if let Some(ref origin) = webauthn.origin { wa.origin = origin.clone(); }
+ if let Some(ref id) = webauthn.id { wa.id = id.clone(); }
} else {
- tfa.webauthn = Some(WebauthnConfig::try_build_from(webauthn)?);
+ let rp = webauthn.rp.unwrap();
+ let origin = webauthn.origin.unwrap();
+ let id = webauthn.id.unwrap();
+ tfa.webauthn = Some(WebauthnConfig { rp, origin, id });
}
tfa::write(&tfa)?;