diff options
author | Vika <vika@fireburn.ru> | 2023-07-09 01:31:35 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2023-07-09 01:31:35 +0300 |
commit | 46a37df2184851f6df35d85b479137caa7d6162b (patch) | |
tree | 572ebf61ebfc4a8ecaff28d77d84dac84b7fa20c | |
parent | 49cd7ac49aad4d60719979bae494ddf15ea37fa1 (diff) | |
download | kittybox-46a37df2184851f6df35d85b479137caa7d6162b.tar.zst |
indieauth/backend/fs: debug tracing
-rw-r--r-- | kittybox-rs/src/indieauth/backend/fs.rs | 7 |
1 files changed, 6 insertions, 1 deletions
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<bool> { 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 } |