diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2023-12-13 16:09:01 +0100 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2023-12-13 16:09:01 +0100 |
commit | 064a1077c8c66fe8d3ee71f831c930e1ddfbc34a (patch) | |
tree | 41d8556aa5d871921a64b081ba157ade212558d8 /src/login/static_provider.rs | |
parent | 47e25cd7f710fcd82356377cf48eccf9f65d31cc (diff) | |
download | aerogramme-064a1077c8c66fe8d3ee71f831c930e1ddfbc34a.tar.gz aerogramme-064a1077c8c66fe8d3ee71f831c930e1ddfbc34a.zip |
it compiles again!
Diffstat (limited to 'src/login/static_provider.rs')
-rw-r--r-- | src/login/static_provider.rs | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/src/login/static_provider.rs b/src/login/static_provider.rs index 7fadf2f..178d97e 100644 --- a/src/login/static_provider.rs +++ b/src/login/static_provider.rs @@ -6,7 +6,6 @@ use anyhow::{anyhow, bail, Result}; use async_trait::async_trait; use crate::config::*; -use crate::cryptoblob::{Key, SecretKey}; use crate::login::*; use crate::storage; @@ -82,19 +81,8 @@ impl LoginProvider for StaticLoginProvider { }), }; - let keys = match &user.crypto_root { /*(&user.master_key, &user.secret_key) {*/ - CryptographyRoot::ClearText { master_key: m, secret_key: s } => { - let master_key = - Key::from_slice(&base64::decode(m)?).ok_or(anyhow!("Invalid master key"))?; - let secret_key = SecretKey::from_slice(&base64::decode(s)?) - .ok_or(anyhow!("Invalid secret key"))?; - CryptoKeys::open_without_password(&storage, &master_key, &secret_key).await? - } - CryptographyRoot::PasswordProtected { root_blob } => { - CryptoKeys::open(password, root_blob).await? - } - CryptographyRoot::Keyring => unimplemented!(), - }; + let cr = CryptoRoot(user.crypto_root); + let keys = cr.crypto_keys(password)?; tracing::debug!(user=%username, "logged"); Ok(Credentials { storage, keys }) @@ -118,8 +106,8 @@ impl LoginProvider for StaticLoginProvider { }), }; - let k2v_client = storage.row_store()?; - let (_, public_key) = CryptoKeys::load_salt_and_public(&k2v_client).await?; + let cr = CryptoRoot(user.crypto_root); + let public_key = cr.public_key()?; Ok(PublicCredentials { storage, |