tustvold commented on code in PR #3698:
URL: https://github.com/apache/arrow-rs/pull/3698#discussion_r1103848388
##########
object_store/src/azure/mod.rs:
##########
@@ -887,6 +900,12 @@ impl MicrosoftAzureBuilder {
self
}
+ /// Set if the Azure Cli should be used for acquiring access token
+ pub fn with_use_azure_cli(mut self, use_azure_cli: bool) -> Self {
Review Comment:
It would be nice to include a link to some sort of reference here, I
struggled to find something that clearly documented this CLI interface
:sweat_smile:
##########
object_store/src/azure/credential.rs:
##########
@@ -540,6 +548,113 @@ impl TokenCredential for WorkloadIdentityOAuthProvider {
}
}
+mod az_cli_date_format {
+ use chrono::{DateTime, TimeZone};
+ use serde::{self, Deserialize, Deserializer};
+
+ pub fn deserialize<'de, D>(
+ deserializer: D,
+ ) -> Result<DateTime<chrono::Local>, D::Error>
+ where
+ D: Deserializer<'de>,
+ {
+ let s = String::deserialize(deserializer)?;
+ // expiresOn from azure cli uses the local timezone
+ let date = chrono::NaiveDateTime::parse_from_str(&s, "%Y-%m-%d
%H:%M:%S.%6f")
+ .map_err(serde::de::Error::custom)?;
+ chrono::Local
+ .from_local_datetime(&date)
+ .single()
+ .ok_or(serde::de::Error::custom(
+ "azure cli returned ambiguous expiry date",
+ ))
+ }
+}
+
+#[derive(Debug, Clone, Deserialize)]
+#[serde(rename_all = "camelCase")]
+struct AzureCliTokenResponse {
Review Comment:
Is it worth deserializing `tokenType` also and ensuring it matches `Bearer`?
##########
object_store/src/azure/client.rs:
##########
@@ -169,6 +169,18 @@ impl AzureClient {
CredentialProvider::AccessKey(key) => {
Ok(AzureCredential::AccessKey(key.to_owned()))
}
+ CredentialProvider::BearerToken(token) => {
+ Ok(AzureCredential::AuthorizationToken(
+ // we do the conversion to a HeaderValue here, since it is
fallible
+ // and we wna to use it in an infallible function
Review Comment:
```suggestion
// and we want to use it in an infallible function
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]