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, pub login_ldap: Option, @@ -19,10 +15,23 @@ pub struct Config { pub imap: Option, } +pub type LoginStaticConfig = HashMap; + #[derive(Serialize, Deserialize, Debug, Clone)] -pub struct LoginStaticConfig { - pub default_bucket: Option, - pub users: HashMap, +pub enum StaticStorage { + Garage(StaticGarageConfig), + InMemory, +} + +#[derive(Serialize, Deserialize, Debug, Clone)] +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, } #[derive(Serialize, Deserialize, Debug, Clone)] @@ -31,10 +40,6 @@ pub struct LoginStaticUser { pub email_addresses: Vec, pub password: String, - pub aws_access_key_id: String, - pub aws_secret_access_key: String, - pub bucket: Option, - pub user_secret: String, #[serde(default)] pub alternate_user_secrets: Vec, @@ -44,26 +49,42 @@ pub struct LoginStaticUser { } #[derive(Serialize, Deserialize, Debug, Clone)] -pub struct LoginLdapConfig { - pub ldap_server: String, +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, + pub default_bucket: Option, +} + +#[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, pub bind_password: Option, - 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, - pub bucket: Option, - pub bucket_attr: Option, + // 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,