From 1dcb11643c783096e1b52bf48d6b76121504e6bd Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Thu, 19 May 2022 15:14:36 +0200 Subject: CLI skeleton --- src/login/mod.rs | 32 +++++++++++++++++++------------- src/login/static_provider.rs | 17 +++++++++++------ 2 files changed, 30 insertions(+), 19 deletions(-) (limited to 'src/login') diff --git a/src/login/mod.rs b/src/login/mod.rs index 4022962..4130496 100644 --- a/src/login/mod.rs +++ b/src/login/mod.rs @@ -53,12 +53,6 @@ impl Credentials { pub fn bucket(&self) -> &str { self.storage.bucket.as_str() } - pub fn dump_config(&self) { - println!("aws_access_key_id = \"{}\"", self.storage.aws_access_key_id); - println!("aws_secret_access_key = \"{}\"", self.storage.aws_secret_access_key); - println!("master_key = \"{}\"", base64::encode(&self.keys.master)); - println!("secret_key = \"{}\"", base64::encode(&self.keys.secret)); - } } impl StorageCredentials { @@ -93,28 +87,40 @@ impl StorageCredentials { } impl CryptoKeys { - pub fn init(storage: &StorageCredentials) -> Result { + pub async fn init(storage: &StorageCredentials, password: &str) -> Result { unimplemented!() } - pub fn init_without_password(storage: &StorageCredentials, master_key: &Key, secret_key: &SecretKey) -> Result { + pub async fn init_without_password( + storage: &StorageCredentials, + master_key: &Key, + secret_key: &SecretKey, + ) -> Result { unimplemented!() } - pub fn open(storage: &StorageCredentials, password: &str) -> Result { + pub async fn open(storage: &StorageCredentials, password: &str) -> Result { unimplemented!() } - pub fn open_without_password(storage: &StorageCredentials, master_key: &Key, secret_key: &SecretKey) -> Result { + pub async fn open_without_password( + storage: &StorageCredentials, + master_key: &Key, + secret_key: &SecretKey, + ) -> Result { unimplemented!() } - pub fn add_password(&self, storage: &StorageCredentials, password: &str) -> Result<()> { + pub async fn add_password(&self, storage: &StorageCredentials, password: &str) -> Result<()> { unimplemented!() } - pub fn remove_password(&self, storage: &StorageCredentials, password: &str, allow_remove_all: bool) -> Result<()> { + pub async fn delete_password( + &self, + storage: &StorageCredentials, + password: &str, + allow_delete_all: bool, + ) -> Result<()> { unimplemented!() } } - diff --git a/src/login/static_provider.rs b/src/login/static_provider.rs index d7d791a..3ef8d89 100644 --- a/src/login/static_provider.rs +++ b/src/login/static_provider.rs @@ -58,19 +58,24 @@ impl LoginProvider for StaticLoginProvider { .ok_or(anyhow!("Invalid master key"))?; let secret_key = SecretKey::from_slice(&base64::decode(m)?) .ok_or(anyhow!("Invalid secret key"))?; - CryptoKeys::open_without_password(&storage, &master_key, &secret_key)? + CryptoKeys::open_without_password(&storage, &master_key, &secret_key).await? } (None, None) => { - CryptoKeys::open(&storage, password)? + CryptoKeys::open(&storage, password).await? } _ => bail!("Either both master and secret key or none of them must be specified for user"), }; - Ok(Credentials { - storage, - keys, - }) + Ok(Credentials { storage, keys }) } } } } + +pub fn hash_password(password: &str) -> String { + unimplemented!() +} + +pub fn verify_password(password: &str, hash: &str) -> bool { + unimplemented!() +} -- cgit v1.2.3