aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2023-11-21 09:04:54 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2023-11-21 09:04:54 +0100
commitbd6c3464e609dc76e119457ea583af0f08eeabb4 (patch)
tree0d7859feaa93616bb9cd162bb330ed15d34185d6 /src
parent36f4050a40c3ba7b9637a973063b6b5549a2c208 (diff)
downloadaerogramme-bd6c3464e609dc76e119457ea583af0f08eeabb4.tar.gz
aerogramme-bd6c3464e609dc76e119457ea583af0f08eeabb4.zip
remove old storagecredentials
Diffstat (limited to 'src')
-rw-r--r--src/login/mod.rs68
-rw-r--r--src/login/static_provider.rs5
2 files changed, 5 insertions, 68 deletions
diff --git a/src/login/mod.rs b/src/login/mod.rs
index a150829..52d9829 100644
--- a/src/login/mod.rs
+++ b/src/login/mod.rs
@@ -51,17 +51,6 @@ pub struct PublicCredentials {
pub public_key: PublicKey,
}
-/// The struct StorageCredentials contains access key to an S3 and K2V bucket
-#[derive(Clone, Debug, Hash, PartialEq, Eq)]
-pub struct StorageCredentials {
- pub s3_region: Region,
- pub k2v_region: Region,
-
- pub aws_access_key_id: String,
- pub aws_secret_access_key: String,
- pub bucket: String,
-}
-
/// The struct UserSecrets represents intermediary secrets that are mixed in with the user's
/// password when decrypting the cryptographic keys that are stored in their bucket.
/// These secrets should be stored somewhere else (e.g. in the LDAP server or in the
@@ -87,24 +76,6 @@ pub struct CryptoKeys {
pub public: PublicKey,
}
-/// A custom S3 region, composed of a region name and endpoint.
-/// We use this instead of rusoto_signature::Region so that we can
-/// derive Hash and Eq
-#[derive(Clone, Debug, Hash, PartialEq, Eq)]
-pub struct Region {
- pub name: String,
- pub endpoint: String,
-}
-
-impl Region {
- pub fn as_rusoto_region(&self) -> rusoto_signature::Region {
- rusoto_signature::Region::Custom {
- name: self.name.clone(),
- endpoint: self.endpoint.clone(),
- }
- }
-}
-
// ----
@@ -117,45 +88,6 @@ impl Credentials {
}
}
-impl StorageCredentials {
- pub fn k2v_client(&self) -> Result<K2vClient> {
- let aws_creds = AwsCredentials::new(
- self.aws_access_key_id.clone(),
- self.aws_secret_access_key.clone(),
- None,
- None,
- );
-
- Ok(K2vClient::new(
- self.k2v_region.as_rusoto_region(),
- self.bucket.clone(),
- aws_creds,
- None,
- )?)
- }
-
- pub fn s3_client(&self) -> Result<S3Client> {
- let aws_creds_provider = StaticProvider::new_minimal(
- self.aws_access_key_id.clone(),
- self.aws_secret_access_key.clone(),
- );
-
- let connector = hyper_rustls::HttpsConnectorBuilder::new()
- .with_native_roots()
- .https_or_http()
- .enable_http1()
- .enable_http2()
- .build();
- let client = HttpClient::from_connector(connector);
-
- Ok(S3Client::new_with(
- client,
- aws_creds_provider,
- self.s3_region.as_rusoto_region(),
- ))
- }
-}
-
impl CryptoKeys {
pub async fn init(
storage: &StorageCredentials,
diff --git a/src/login/static_provider.rs b/src/login/static_provider.rs
index df1432f..d013c6f 100644
--- a/src/login/static_provider.rs
+++ b/src/login/static_provider.rs
@@ -106,6 +106,7 @@ impl LoginProvider for StaticLoginProvider {
Some(u) => u,
};
+ /*
let bucket = user
.bucket
.clone()
@@ -120,6 +121,10 @@ impl LoginProvider for StaticLoginProvider {
aws_access_key_id: user.aws_access_key_id.clone(),
aws_secret_access_key: user.aws_secret_access_key.clone(),
bucket,
+ };*/
+ let storage: storage::Builders = match user.storage {
+ StaticStorage::InMemory => X,
+ StaticStorage::Garage => Y,
};
let k2v_client = storage.k2v_client()?;