From 306c1e56b0dc457b59c47693c62fcab668398020 Mon Sep 17 00:00:00 2001 From: Katharina Fey Date: Sat, 8 Sep 2018 23:51:03 +0200 Subject: Starting work on the lockchain-core --> lockchain-files userstore mapper --- lockchain-core/src/users/mod.rs | 3 ++- lockchain-files/src/lib.rs | 8 ++++++-- lockchain-files/src/userstore.rs | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 lockchain-files/src/userstore.rs diff --git a/lockchain-core/src/users/mod.rs b/lockchain-core/src/users/mod.rs index 5fe1601..4086fac 100644 --- a/lockchain-core/src/users/mod.rs +++ b/lockchain-core/src/users/mod.rs @@ -19,11 +19,12 @@ mod rights; mod tokens; mod secrets; -pub mod userstore; +mod userstore; pub use self::auth::pam_authenticate; pub use self::tokens::Token; pub use self::user::User; +pub use self::userstore::UserStore; pub use errors::AuthError; pub use self::rights::{Access, Role}; diff --git a/lockchain-files/src/lib.rs b/lockchain-files/src/lib.rs index af7271e..a7941e9 100644 --- a/lockchain-files/src/lib.rs +++ b/lockchain-files/src/lib.rs @@ -57,17 +57,19 @@ extern crate serde; use lcc::traits::{Body, LoadRecord, Vault}; use lcc::{ errors::VaultError, - users::{Access, Token}, + users::{Access, Token, UserStore}, Generator, MetaDomain, Payload, Record, VaultMetadata, }; use std::collections::HashMap; mod config; mod fs; +mod userstore; mod utils; pub use config::{ConfigError, VaultConfig}; use fs::{FileType, Filesystem}; +use userstore::UserStoreMapper; /// Persistence mapper to a folder and file structure /// @@ -85,13 +87,13 @@ use fs::{FileType, Filesystem}; /// /// The vault folder is safe to copy around – /// all vault metadata is kept inside it. -#[derive(Debug)] pub struct DataVault { meta_info: (String, String), config: VaultConfig, records: HashMap>, metadata: HashMap, fs: Filesystem, + users: UserStoreMapper, } impl DataVault { @@ -126,6 +128,7 @@ impl Vault for DataVault { config: VaultConfig::new(), metadata: HashMap::new(), fs: Filesystem::new(&gen.location.unwrap(), &gen.name.unwrap()), + users: UserStoreMapper::new(UserStore::new()), }.initialize(), )) } @@ -154,6 +157,7 @@ impl Vault for DataVault { config: VaultConfig::new(), metadata: HashMap::new(), fs: Filesystem::new(location, name), + users: UserStoreMapper::new(UserStore::new()), }.load() } diff --git a/lockchain-files/src/userstore.rs b/lockchain-files/src/userstore.rs new file mode 100644 index 0000000..1d01db6 --- /dev/null +++ b/lockchain-files/src/userstore.rs @@ -0,0 +1,15 @@ +//! This module maps the lockchain internal `UserStore` into a +//! structure that can be saved to disk. + +use lcc::users::UserStore; + +#[derive(Debug)] +pub struct UserStoreMapper { + inner: UserStore, +} + +impl UserStoreMapper { + pub fn new(store: UserStore) -> Store { + Self { inner: store } + } +} -- cgit v1.2.3