From c86cd21da7e5797a33f22c06004ec5c32bdeac05 Mon Sep 17 00:00:00 2001 From: Katharina Fey Date: Thu, 6 Sep 2018 00:44:32 +0200 Subject: Removing deprecated `UserStore` and `KeyStore` into new `users::UserStore` and fixing all resulting code issues --- lockchain-core/src/crypto/mod.rs | 1 - lockchain-core/src/lib.rs | 2 +- lockchain-core/src/users/mod.rs | 9 --------- lockchain-files/src/lib.rs | 32 +++++++++++++++++++++++++------- lockchain-http/src/handlers.rs | 2 +- 5 files changed, 27 insertions(+), 19 deletions(-) diff --git a/lockchain-core/src/crypto/mod.rs b/lockchain-core/src/crypto/mod.rs index ef52912..11aace0 100644 --- a/lockchain-core/src/crypto/mod.rs +++ b/lockchain-core/src/crypto/mod.rs @@ -19,4 +19,3 @@ pub mod hashing; pub use self::data::PackedData; pub use self::keys::{Key, KeyType}; -pub use users::KeyStore; \ No newline at end of file diff --git a/lockchain-core/src/lib.rs b/lockchain-core/src/lib.rs index 9c9ba95..b3d0931 100644 --- a/lockchain-core/src/lib.rs +++ b/lockchain-core/src/lib.rs @@ -76,7 +76,7 @@ mod record; pub mod traits; pub mod users; -mod initialise; +pub mod initialise; pub use self::crypto::PackedData; pub use self::meta::{MetaDomain, VaultMetadata}; diff --git a/lockchain-core/src/users/mod.rs b/lockchain-core/src/users/mod.rs index 3fce31c..5fe1601 100644 --- a/lockchain-core/src/users/mod.rs +++ b/lockchain-core/src/users/mod.rs @@ -12,27 +12,18 @@ //! //! `User` is also a serialisable struct which contains important //! data to load and store them into a metadata store. -#![allow(deprecated)] mod auth; mod user; mod rights; mod tokens; -mod keystore; mod secrets; pub mod userstore; pub use self::auth::pam_authenticate; -pub use self::keystore::KeyStore; pub use self::tokens::Token; pub use self::user::User; pub use errors::AuthError; pub use self::rights::{Access, Role}; - -use std::collections::HashMap; -use { - meta::MetaDomain, - traits::{AutoEncoder, Base64AutoEncoder}, -}; diff --git a/lockchain-files/src/lib.rs b/lockchain-files/src/lib.rs index 320714b..97912be 100644 --- a/lockchain-files/src/lib.rs +++ b/lockchain-files/src/lib.rs @@ -55,16 +55,19 @@ extern crate serde_derive; extern crate serde; use lcc::traits::{Body, LoadRecord, Vault}; -use lcc::{users::Token, MetaDomain, Payload, Record, VaultMetadata}; +use lcc::{ + initialise::Generator, + users::{Access, Token}, + MetaDomain, Payload, Record, VaultMetadata, +}; use std::collections::HashMap; +mod config; mod fs; mod utils; -mod config; +pub use config::{ConfigError, VaultConfig}; use fs::{FileType, Filesystem}; -pub use config::{VaultConfig, ConfigError}; - /// Persistence mapper to a folder and file structure /// @@ -112,16 +115,31 @@ impl DataVault { impl LoadRecord for DataVault {} impl Vault for DataVault { - fn new(name: &str, location: &str) -> DataVault { + fn new(gen: Generator) -> DataVault { Self { - meta_info: (name.into(), location.into()), + meta_info: ( + gen.name.clone().unwrap().into(), + gen.location.clone().unwrap().into(), + ), records: HashMap::new(), config: VaultConfig::new(), metadata: HashMap::new(), - fs: Filesystem::new(location, name), + fs: Filesystem::new(&gen.location.unwrap(), &gen.name.unwrap()), }.initialize() } + fn create_user( + &mut self, + token: Token, + username: &str, + secret: &str, + access: Vec, + ) -> Result<(), ()> { + unimplemented!() + } + + fn delete_user(&mut self, token: Token, username: &str) {} + // Checking if a vault exists is basically checking it's config // against the compatible version of this library. // diff --git a/lockchain-http/src/handlers.rs b/lockchain-http/src/handlers.rs index 8ce44da..287ef54 100644 --- a/lockchain-http/src/handlers.rs +++ b/lockchain-http/src/handlers.rs @@ -46,7 +46,7 @@ where (&item.location).into() }; - state.add_vault(&item.name, V::new(&item.name, location.to_str().unwrap())); + // state.add_vault(&item.name, V::new(&item.name, location.to_str().unwrap())); Json(Response::Success) } -- cgit v1.2.3