From cd972f9984028a6a7dd792ce4d90a3e414f140ea Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Fri, 7 Jun 2024 16:10:00 +0800 Subject: [PATCH] feat(core): Azblob supports azure workload identity Signed-off-by: Xuanwo --- bin/ofs/Cargo.lock | 4 ++-- bin/oli/Cargo.lock | 4 ++-- core/Cargo.lock | 4 ++-- core/Cargo.toml | 2 +- core/src/services/azblob/backend.rs | 28 ++++++++++++++++++---------- 5 files changed, 25 insertions(+), 17 deletions(-) diff --git a/bin/ofs/Cargo.lock b/bin/ofs/Cargo.lock index 09a1460f7af..42f4e57175e 100644 --- a/bin/ofs/Cargo.lock +++ b/bin/ofs/Cargo.lock @@ -1139,9 +1139,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqsign" -version = "0.15.0" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01edce6b6c31a16ebc7525ac58c747a6d78bbce33e76bbebd350d6bc25b23e06" +checksum = "70fe66d4cd0b5ed9b1abbfe639bf6baeaaf509f7da2d51b31111ba945be59286" dependencies = [ "anyhow", "async-trait", diff --git a/bin/oli/Cargo.lock b/bin/oli/Cargo.lock index 1a1f0395090..eca6b2b666f 100644 --- a/bin/oli/Cargo.lock +++ b/bin/oli/Cargo.lock @@ -2605,9 +2605,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqsign" -version = "0.15.0" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01edce6b6c31a16ebc7525ac58c747a6d78bbce33e76bbebd350d6bc25b23e06" +checksum = "70fe66d4cd0b5ed9b1abbfe639bf6baeaaf509f7da2d51b31111ba945be59286" dependencies = [ "anyhow", "async-trait", diff --git a/core/Cargo.lock b/core/Cargo.lock index 95683524759..630de754429 100644 --- a/core/Cargo.lock +++ b/core/Cargo.lock @@ -6130,9 +6130,9 @@ dependencies = [ [[package]] name = "reqsign" -version = "0.15.0" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01edce6b6c31a16ebc7525ac58c747a6d78bbce33e76bbebd350d6bc25b23e06" +checksum = "70fe66d4cd0b5ed9b1abbfe639bf6baeaaf509f7da2d51b31111ba945be59286" dependencies = [ "anyhow", "async-trait", diff --git a/core/Cargo.toml b/core/Cargo.toml index 60aa5ae958a..6cba0f70079 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -264,7 +264,7 @@ sha1 = { version = "0.10.6", optional = true } sha2 = { version = "0.10", optional = true } # For http based services. -reqsign = { version = "0.15.0", default-features = false, optional = true } +reqsign = { version = "0.15.2", default-features = false, optional = true } # for services-atomic-server atomic_lib = { version = "0.34.5", optional = true } diff --git a/core/src/services/azblob/backend.rs b/core/src/services/azblob/backend.rs index 2001881d091..1f63290beab 100644 --- a/core/src/services/azblob/backend.rs +++ b/core/src/services/azblob/backend.rs @@ -439,16 +439,24 @@ impl Builder for AzblobBuilder { })? }; - let config_loader = AzureStorageConfig { - account_name: self - .config - .account_name - .clone() - .or_else(|| infer_storage_name_from_endpoint(endpoint.as_str())), - account_key: self.config.account_key.clone(), - sas_token: self.config.sas_token.clone(), - ..Default::default() - }; + let mut config_loader = AzureStorageConfig::default().from_env(); + + if let Some(v) = self + .config + .account_name + .clone() + .or_else(|| infer_storage_name_from_endpoint(endpoint.as_str())) + { + config_loader.account_name = Some(v); + } + + if let Some(v) = self.config.account_key.clone() { + config_loader.account_key = Some(v); + } + + if let Some(v) = self.config.sas_token.clone() { + config_loader.sas_token = Some(v); + } let encryption_key = match &self.config.encryption_key {