aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/config.rs2
-rw-r--r--src/login/static_provider.rs25
-rw-r--r--src/server.rs13
-rw-r--r--src/storage/in_memory.rs2
4 files changed, 17 insertions, 25 deletions
diff --git a/src/config.rs b/src/config.rs
index 2a55036..477968e 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -46,6 +46,8 @@ pub struct LoginStaticUser {
pub master_key: Option<String>,
pub secret_key: Option<String>,
+
+ pub storage: StaticStorage,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
diff --git a/src/login/static_provider.rs b/src/login/static_provider.rs
index 378a863..df1432f 100644
--- a/src/login/static_provider.rs
+++ b/src/login/static_provider.rs
@@ -10,18 +10,13 @@ use crate::login::*;
use crate::storage;
pub struct StaticLoginProvider {
- default_bucket: Option<String>,
users: HashMap<String, Arc<LoginStaticUser>>,
users_by_email: HashMap<String, Arc<LoginStaticUser>>,
-
- k2v_region: Region,
- s3_region: Region,
}
impl StaticLoginProvider {
- pub fn new(config: LoginStaticConfig, k2v_region: Region, s3_region: Region) -> Result<Self> {
+ pub fn new(config: LoginStaticConfig) -> Result<Self> {
let users = config
- .users
.into_iter()
.map(|(k, v)| (k, Arc::new(v)))
.collect::<HashMap<_, _>>();
@@ -36,11 +31,8 @@ impl StaticLoginProvider {
}
Ok(Self {
- default_bucket: config.default_bucket,
users,
users_by_email,
- k2v_region,
- s3_region,
})
}
}
@@ -59,23 +51,30 @@ impl LoginProvider for StaticLoginProvider {
bail!("Wrong password");
}
+ /*
tracing::debug!(user=%username, "fetch bucket");
let bucket = user
.bucket
.clone()
.or_else(|| self.default_bucket.clone())
.ok_or(anyhow!(
- "No bucket configured and no default bucket specieid"
- ))?;
+ "No bucket configured and no default bucket specified"
+ ))?;*/
tracing::debug!(user=%username, "fetch keys");
- let storage = StorageCredentials {
+ let storage: storage::Builders = match user.storage {
+ StaticStorage::InMemory => Box::new(storage::in_memory::FullMem {}),
+ StaticStorage::Garage(c) => Box::new(storage::garage::GrgCreds {}),
+ };
+
+ /*
+ StorageCredentials {
k2v_region: self.k2v_region.clone(),
s3_region: self.s3_region.clone(),
aws_access_key_id: user.aws_access_key_id.clone(),
aws_secret_access_key: user.aws_secret_access_key.clone(),
bucket,
- };
+ };*/
let keys = match (&user.master_key, &user.secret_key) {
(Some(m), Some(s)) => {
diff --git a/src/server.rs b/src/server.rs
index f0eb35f..3485a61 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -61,18 +61,9 @@ impl Server {
}
fn build(config: Config) -> Result<(ArcLoginProvider, Option<LmtpConfig>, Option<ImapConfig>)> {
- let s3_region = Region {
- name: config.aws_region.clone(),
- endpoint: config.s3_endpoint,
- };
- let k2v_region = Region {
- name: config.aws_region,
- endpoint: config.k2v_endpoint,
- };
-
let lp: ArcLoginProvider = match (config.login_static, config.login_ldap) {
- (Some(st), None) => Arc::new(StaticLoginProvider::new(st, k2v_region, s3_region)?),
- (None, Some(ld)) => Arc::new(LdapLoginProvider::new(ld, k2v_region, s3_region)?),
+ (Some(st), None) => Arc::new(StaticLoginProvider::new(st)?),
+ (None, Some(ld)) => Arc::new(LdapLoginProvider::new(ld)?),
(Some(_), Some(_)) => {
bail!("A single login provider must be set up in config file")
}
diff --git a/src/storage/in_memory.rs b/src/storage/in_memory.rs
index a2ad04f..cde2335 100644
--- a/src/storage/in_memory.rs
+++ b/src/storage/in_memory.rs
@@ -30,7 +30,7 @@ impl IRowStore for MemStore {
}
fn select(&self, selector: Selector) -> AsyncResult<Vec<RowValue>> {
- unimplemented!();
+ unimplemented!()
}
fn rm(&self, selector: Selector) -> AsyncResult<()> {