Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 108 additions & 43 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 14 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,16 @@ aws-smithy-runtime-api = { version = "1.7.3", default-features = false, optional
aws-smithy-types = { version = "1.2.11", default-features = false, features = ["rt-tokio"], optional = true }

# Azure
azure_core = { version = "0.17", default-features = false, features = ["enable_reqwest"], optional = true }
azure_identity = { version = "0.17", default-features = false, features = ["enable_reqwest"], optional = true }
azure_storage = { version = "0.17", default-features = false, optional = true }
azure_storage_blobs = { version = "0.17", default-features = false, optional = true }
azure_core = { version = "0.25", default-features = false, features = ["reqwest"], optional = true }
azure_identity = { version = "0.25", default-features = false, features = ["reqwest"], optional = true }

# Azure Storage
azure_storage = { version = "0.21", default-features = false, optional = true }
azure_storage_blobs = { version = "0.21", default-features = false, optional = true }

# Needed to bridge with outdated version of azure_core used in azure_storage*
azure_core_for_storage = { package = "azure_core", version = "0.21.0" }


# OpenDAL
opendal = { version = "0.53", default-features = false, features = ["services-webhdfs"], optional = true }
Expand Down Expand Up @@ -432,10 +438,10 @@ openssl-src = { version = "300", default-features = false, features = ["force-en
approx = "0.5.1"
assert_cmd = { version = "2.0.17", default-features = false }
aws-smithy-runtime = { version = "1.8.3", default-features = false, features = ["tls-rustls"] }
azure_core = { version = "0.17", default-features = false, features = ["enable_reqwest", "azurite_workaround"] }
azure_identity = { version = "0.17", default-features = false, features = ["enable_reqwest"] }
azure_storage_blobs = { version = "0.17", default-features = false, features = ["azurite_workaround"] }
azure_storage = { version = "0.17", default-features = false }
azure_core = { version = "0.25", default-features = false, features = ["reqwest", "azurite_workaround"] }
azure_identity = { version = "0.25", default-features = false, features = ["reqwest"] }
azure_storage_blobs = { version = "0.21", default-features = false, features = ["azurite_workaround"] }
azure_storage = { version = "0.21", default-features = false }
base64 = "0.22.1"
criterion = { version = "0.6.0", features = ["html_reports", "async_tokio"] }
itertools = { version = "0.14.0", default-features = false, features = ["use_alloc"] }
Expand Down
3 changes: 2 additions & 1 deletion src/sinks/azure_blob/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use std::{
num::NonZeroU32,
};

use azure_core::{error::HttpError, prelude::Range};
use azure_core::error::HttpError;
use azure_core_for_storage::prelude::Range;
use azure_storage_blobs::prelude::*;
use bytes::{Buf, BytesMut};
use flate2::read::GzDecoder;
Expand Down
76 changes: 76 additions & 0 deletions src/sinks/azure_common/azure_credential_interop.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* This file is derived from:
* https://github.com/Metaswitch/apt-transport-blob/blob/0d2818400300a73a45b8af79f69489f567ae3bc4/src/azure_credential_interop.rs
*
* Originally licensed under the MIT License by Alianza, Inc.
*
* MIT License
*
* Copyright (c) Alianza, Inc
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE
*/

// Interop module for Azure Credentials

use azure_core::credentials::TokenCredential;
use azure_core_for_storage::error::{Error, ErrorKind};
use std::sync::Arc;

#[derive(Clone, Debug)]
pub(crate) struct TokenCredentialInterop {
// Credential
credential: Arc<dyn TokenCredential>,
}

impl TokenCredentialInterop {
/// Create a new `TokenCredentialInterop` from a `DefaultAzureCredential`
pub fn new(credential: Arc<dyn TokenCredential>) -> Self {
Self { credential }
}
}

#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)]
impl azure_core_for_storage::auth::TokenCredential for TokenCredentialInterop {
async fn get_token(
&self,
scopes: &[&str],
) -> azure_core_for_storage::Result<azure_core_for_storage::auth::AccessToken> {
let access_token = self
.credential
.get_token(scopes, None)
.await
.map_err(|err| Error::new(ErrorKind::Credential, err))?;

// Construct an old AccessToken from the information in the new AccessToken.
let secret = access_token.token.secret().to_string();
let access_token = azure_core_for_storage::auth::AccessToken {
token: secret.into(),
expires_on: access_token.expires_on,
};

// Return the new AccessToken
Ok(access_token)
}

async fn clear_cache(&self) -> azure_core_for_storage::Result<()> {
Ok(())
}
}
Loading
Loading