summaryrefslogtreecommitdiffstats
path: root/adenosine-pds/src/db.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2022-11-04 19:16:01 -0700
committerBryan Newbold <bnewbold@robocracy.org>2022-11-04 19:16:01 -0700
commitbc8493998d90799551c5e0703bbb4a6e69d2478a (patch)
tree482d0360ae7f395568e3cdf0fd48d2e5313e9eb9 /adenosine-pds/src/db.rs
parent5f220855db95d006e4168356759a5b871899d759 (diff)
downloadadenosine-bc8493998d90799551c5e0703bbb4a6e69d2478a.tar.gz
adenosine-bc8493998d90799551c5e0703bbb4a6e69d2478a.zip
pds: basic repo CRUD coming together
Diffstat (limited to 'adenosine-pds/src/db.rs')
-rw-r--r--adenosine-pds/src/db.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/adenosine-pds/src/db.rs b/adenosine-pds/src/db.rs
index 17006cb..e6b957c 100644
--- a/adenosine-pds/src/db.rs
+++ b/adenosine-pds/src/db.rs
@@ -9,6 +9,9 @@ use serde_json::Value;
use std::path::PathBuf;
use std::str::FromStr;
+/// Default is 12, but that is quite slow (on my laptop at least)
+const BCRYPT_COST: u32 = 8;
+
#[cfg(test)]
mod tests {
use super::*;
@@ -78,7 +81,7 @@ impl AtpDatabase {
recovery_pubkey: &str,
) -> Result<()> {
debug!("bcrypt hashing password (can be slow)...");
- let password_bcrypt = bcrypt::hash(password, bcrypt::DEFAULT_COST)?;
+ let password_bcrypt = bcrypt::hash(password, BCRYPT_COST)?;
let mut stmt = self.conn.prepare_cached(
"INSERT INTO account (username, password_bcrypt, email, did, recovery_pubkey) VALUES (?1, ?2, ?3, ?4, ?5)",
)?;
@@ -107,7 +110,7 @@ impl AtpDatabase {
if !bcrypt::verify(password, &password_bcrypt)? {
return Err(anyhow!("password did not match"));
}
- let jwt = keypair.ucan()?;
+ let jwt = keypair.ucan(&did)?;
let mut stmt = self
.conn
.prepare_cached("INSERT INTO session (did, jwt) VALUES (?1, ?2)")?;