aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.rs57
-rw-r--r--src/login/static_provider.rs1
2 files changed, 40 insertions, 18 deletions
diff --git a/src/config.rs b/src/config.rs
index 074c192..2a55036 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -8,10 +8,6 @@ use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Config {
- pub s3_endpoint: String,
- pub k2v_endpoint: String,
- pub aws_region: String,
-
pub login_static: Option<LoginStaticConfig>,
pub login_ldap: Option<LoginLdapConfig>,
@@ -19,21 +15,30 @@ pub struct Config {
pub imap: Option<ImapConfig>,
}
+pub type LoginStaticConfig = HashMap<String, LoginStaticUser>;
+
#[derive(Serialize, Deserialize, Debug, Clone)]
-pub struct LoginStaticConfig {
- pub default_bucket: Option<String>,
- pub users: HashMap<String, LoginStaticUser>,
+pub enum StaticStorage {
+ Garage(StaticGarageConfig),
+ InMemory,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
-pub struct LoginStaticUser {
- #[serde(default)]
- pub email_addresses: Vec<String>,
- pub password: String,
+pub struct StaticGarageConfig {
+ pub s3_endpoint: String,
+ pub k2v_endpoint: String,
+ pub aws_region: String,
pub aws_access_key_id: String,
pub aws_secret_access_key: String,
pub bucket: Option<String>,
+}
+
+#[derive(Serialize, Deserialize, Debug, Clone)]
+pub struct LoginStaticUser {
+ #[serde(default)]
+ pub email_addresses: Vec<String>,
+ pub password: String,
pub user_secret: String,
#[serde(default)]
@@ -44,26 +49,42 @@ pub struct LoginStaticUser {
}
#[derive(Serialize, Deserialize, Debug, Clone)]
+pub enum LdapStorage {
+ Garage(LdapGarageConfig),
+ InMemory,
+}
+
+#[derive(Serialize, Deserialize, Debug, Clone)]
+pub struct LdapGarageConfig {
+ pub s3_endpoint: String,
+ pub k2v_endpoint: String,
+ pub aws_region: String,
+
+ pub aws_access_key_id_attr: String,
+ pub aws_secret_access_key_attr: String,
+ pub bucket_attr: Option<String>,
+ pub default_bucket: Option<String>,
+}
+
+#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct LoginLdapConfig {
+ // LDAP connection info
pub ldap_server: String,
-
#[serde(default)]
pub pre_bind_on_login: bool,
pub bind_dn: Option<String>,
pub bind_password: Option<String>,
-
pub search_base: String,
+
+ // Schema-like info required for Aerogramme's logic
pub username_attr: String,
#[serde(default = "default_mail_attr")]
pub mail_attr: String,
-
- pub aws_access_key_id_attr: String,
- pub aws_secret_access_key_attr: String,
pub user_secret_attr: String,
pub alternate_user_secrets_attr: Option<String>,
- pub bucket: Option<String>,
- pub bucket_attr: Option<String>,
+ // Storage related thing
+ pub storage: LdapStorage,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
diff --git a/src/login/static_provider.rs b/src/login/static_provider.rs
index b9be5a6..378a863 100644
--- a/src/login/static_provider.rs
+++ b/src/login/static_provider.rs
@@ -7,6 +7,7 @@ use async_trait::async_trait;
use crate::config::*;
use crate::cryptoblob::{Key, SecretKey};
use crate::login::*;
+use crate::storage;
pub struct StaticLoginProvider {
default_bucket: Option<String>,