From 46a37df2184851f6df35d85b479137caa7d6162b Mon Sep 17 00:00:00 2001 From: Vika Date: Sun, 9 Jul 2023 01:31:35 +0300 Subject: indieauth/backend/fs: debug tracing --- kittybox-rs/src/indieauth/backend/fs.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'kittybox-rs') diff --git a/kittybox-rs/src/indieauth/backend/fs.rs b/kittybox-rs/src/indieauth/backend/fs.rs index 57bc3bd..600e901 100644 --- a/kittybox-rs/src/indieauth/backend/fs.rs +++ b/kittybox-rs/src/indieauth/backend/fs.rs @@ -14,7 +14,7 @@ const CODE_LENGTH: usize = 16; const TOKEN_LENGTH: usize = 128; const CODE_DURATION: std::time::Duration = std::time::Duration::from_secs(600); -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct FileBackend { path: PathBuf, } @@ -302,6 +302,7 @@ impl AuthBackend for FileBackend { } // Password management. + #[tracing::instrument(skip(password))] async fn verify_password(&self, website: &url::Url, password: String) -> Result { use argon2::{Argon2, password_hash::{PasswordHash, PasswordVerifier}}; @@ -309,6 +310,8 @@ impl AuthBackend for FileBackend { .join(FileBackend::url_to_dir(website)) .join("password"); + tracing::debug!("Reading password for {} from {}", website, password_filename.display()); + match tokio::fs::read_to_string(password_filename).await { Ok(password_hash) => { let parsed_hash = { @@ -327,6 +330,7 @@ impl AuthBackend for FileBackend { } } + #[tracing::instrument(skip(password))] async fn enroll_password(&self, website: &url::Url, password: String) -> Result<()> { use argon2::{Argon2, password_hash::{rand_core::OsRng, PasswordHasher, SaltString}}; @@ -340,6 +344,7 @@ impl AuthBackend for FileBackend { .expect("Hashing a password should not error out") .to_string(); + tracing::debug!("Enrolling password for {} at {}", website, password_filename.display()); tokio::fs::write(password_filename, password_hash.as_bytes()).await } -- cgit 1.4.1