From 02a8537556236437d905cefe8aa2c5d0a96f129a Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Fri, 23 Feb 2024 17:01:51 +0100 Subject: Replace with a single AWS HTTP client --- src/login/ldap_provider.rs | 7 ++++++- src/login/static_provider.rs | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src/login') diff --git a/src/login/ldap_provider.rs b/src/login/ldap_provider.rs index e73e1dc..42c993d 100644 --- a/src/login/ldap_provider.rs +++ b/src/login/ldap_provider.rs @@ -21,6 +21,7 @@ pub struct LdapLoginProvider { storage_specific: StorageSpecific, in_memory_store: storage::in_memory::MemDb, + garage_store: storage::garage::GarageRoot, } enum BucketSource { @@ -91,7 +92,11 @@ impl LdapLoginProvider { mail_attr: config.mail_attr, crypto_root_attr: config.crypto_root_attr, storage_specific: specific, + //@FIXME should be created outside of the login provider + //Login provider should return only a cryptoroot + a storage URI + //storage URI that should be resolved outside... in_memory_store: storage::in_memory::MemDb::new(), + garage_store: storage::garage::GarageRoot::new(), }) } @@ -114,7 +119,7 @@ impl LdapLoginProvider { BucketSource::Attr(a) => get_attr(user, &a)?, }; - storage::garage::GarageBuilder::new(storage::garage::GarageConf { + self.garage_store.user(storage::garage::GarageConf { region: from_config.aws_region.clone(), s3_endpoint: from_config.s3_endpoint.clone(), k2v_endpoint: from_config.k2v_endpoint.clone(), diff --git a/src/login/static_provider.rs b/src/login/static_provider.rs index 1e1ecbf..e190a91 100644 --- a/src/login/static_provider.rs +++ b/src/login/static_provider.rs @@ -25,6 +25,7 @@ pub struct UserDatabase { pub struct StaticLoginProvider { user_db: watch::Receiver, in_memory_store: storage::in_memory::MemDb, + garage_store: storage::garage::GarageRoot, } pub async fn update_user_list(config: PathBuf, up: watch::Sender) -> Result<()> { @@ -84,6 +85,7 @@ impl StaticLoginProvider { Ok(Self { user_db: rx, in_memory_store: storage::in_memory::MemDb::new(), + garage_store: storage::garage::GarageRoot::new(), }) } } @@ -109,7 +111,7 @@ impl LoginProvider for StaticLoginProvider { let storage: storage::Builder = match &user.config.storage { StaticStorage::InMemory => self.in_memory_store.builder(username).await, StaticStorage::Garage(grgconf) => { - storage::garage::GarageBuilder::new(storage::garage::GarageConf { + self.garage_store.user(storage::garage::GarageConf { region: grgconf.aws_region.clone(), k2v_endpoint: grgconf.k2v_endpoint.clone(), s3_endpoint: grgconf.s3_endpoint.clone(), @@ -140,7 +142,7 @@ impl LoginProvider for StaticLoginProvider { let storage: storage::Builder = match &user.config.storage { StaticStorage::InMemory => self.in_memory_store.builder(&user.username).await, StaticStorage::Garage(grgconf) => { - storage::garage::GarageBuilder::new(storage::garage::GarageConf { + self.garage_store.user(storage::garage::GarageConf { region: grgconf.aws_region.clone(), k2v_endpoint: grgconf.k2v_endpoint.clone(), s3_endpoint: grgconf.s3_endpoint.clone(), -- cgit v1.2.3 From 2a084df300dc30d40cf3599c1cb7a90132d5a6e8 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Fri, 23 Feb 2024 17:31:29 +0100 Subject: Also share HTTPClient for K2V --- src/login/ldap_provider.rs | 2 +- src/login/static_provider.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/login') diff --git a/src/login/ldap_provider.rs b/src/login/ldap_provider.rs index 42c993d..0af5676 100644 --- a/src/login/ldap_provider.rs +++ b/src/login/ldap_provider.rs @@ -96,7 +96,7 @@ impl LdapLoginProvider { //Login provider should return only a cryptoroot + a storage URI //storage URI that should be resolved outside... in_memory_store: storage::in_memory::MemDb::new(), - garage_store: storage::garage::GarageRoot::new(), + garage_store: storage::garage::GarageRoot::new()?, }) } diff --git a/src/login/static_provider.rs b/src/login/static_provider.rs index e190a91..79626df 100644 --- a/src/login/static_provider.rs +++ b/src/login/static_provider.rs @@ -85,7 +85,7 @@ impl StaticLoginProvider { Ok(Self { user_db: rx, in_memory_store: storage::in_memory::MemDb::new(), - garage_store: storage::garage::GarageRoot::new(), + garage_store: storage::garage::GarageRoot::new()?, }) } } -- cgit v1.2.3