Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[target.x86_64-unknown-linux-gnu]
linker = "/usr/bin/clang"
rustflags = ["-C", "link-arg=--ld-path=/usr/bin/mold"]
2 changes: 1 addition & 1 deletion pgdog-plugin/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub const __STDC_IEC_60559_COMPLEX__: u32 = 201404;
pub const __STDC_ISO_10646__: u32 = 201706;
pub const __GNU_LIBRARY__: u32 = 6;
pub const __GLIBC__: u32 = 2;
pub const __GLIBC_MINOR__: u32 = 42;
pub const __GLIBC_MINOR__: u32 = 41;
pub const _SYS_CDEFS_H: u32 = 1;
pub const __glibc_c99_flexarr_available: u32 = 1;
pub const __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI: u32 = 0;
Expand Down
16 changes: 14 additions & 2 deletions pgdog/src/auth/scram/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ use base64::prelude::*;

impl AuthenticationProvider for UserPassword {
fn get_password_for(&self, _user: &str) -> Option<PasswordInfo> {
// TODO: This is slow. We should move it to its own thread pool.
let iterations = 4096;
let salt = rand::thread_rng().gen::<[u8; 16]>().to_vec();
let hash = hash_password(&self.password, NonZeroU32::new(iterations).unwrap(), &salt);
// Perform the expensive PBKDF2 computation in a blocking section
// so that we don't stall the async runtime worker.
let hash = tokio::task::block_in_place(|| {
hash_password(&self.password, NonZeroU32::new(iterations).unwrap(), &salt)
});
Some(PasswordInfo::new(hash.to_vec(), iterations as u16, salt))
}
}
Expand Down Expand Up @@ -216,4 +219,13 @@ mod test {
let info = hashed.get_password_for("user");
assert!(info.is_some());
}

#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_user_password_get_password_for_blocking_ok() {
let plain = UserPassword {
password: "secret".to_string(),
};
let info = plain.get_password_for("user");
assert!(info.is_some());
}
}
Loading