This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 929c40bcbd GH-39343: [C++][FS][Azure] Add client secret auth
configuration (#39346)
929c40bcbd is described below
commit 929c40bcbded7184a5f6894db208f16975de4d37
Author: Thomas Newton <[email protected]>
AuthorDate: Fri Dec 22 00:37:29 2023 +0000
GH-39343: [C++][FS][Azure] Add client secret auth configuration (#39346)
### Rationale for this change
Client is a useful Azure authentication
### What changes are included in this PR?
Implement `AzureOptions::ConfigureClientSecretCredential`
### Are these changes tested?
Simple unittest
### Are there any user-facing changes?
Client secret auth is now supported on the Azure filesystem.
* Closes: #39343
Authored-by: Thomas Newton <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
---
cpp/src/arrow/filesystem/azurefs.cc | 10 ++++++++++
cpp/src/arrow/filesystem/azurefs.h | 5 +++++
cpp/src/arrow/filesystem/azurefs_test.cc | 7 +++++++
3 files changed, 22 insertions(+)
diff --git a/cpp/src/arrow/filesystem/azurefs.cc
b/cpp/src/arrow/filesystem/azurefs.cc
index 27bdb5092a..26c2761886 100644
--- a/cpp/src/arrow/filesystem/azurefs.cc
+++ b/cpp/src/arrow/filesystem/azurefs.cc
@@ -113,6 +113,16 @@ Status AzureOptions::ConfigureAccountKeyCredential(const
std::string& account_na
return Status::OK();
}
+Status AzureOptions::ConfigureClientSecretCredential(const std::string&
account_name,
+ const std::string&
tenant_id,
+ const std::string&
client_id,
+ const std::string&
client_secret) {
+ credential_kind_ = CredentialKind::kTokenCredential;
+ token_credential_ =
std::make_shared<Azure::Identity::ClientSecretCredential>(
+ tenant_id, client_id, client_secret);
+ return Status::OK();
+}
+
Status AzureOptions::ConfigureDefaultCredential(const std::string&
account_name) {
credential_kind_ = CredentialKind::kTokenCredential;
token_credential_ =
std::make_shared<Azure::Identity::DefaultAzureCredential>();
diff --git a/cpp/src/arrow/filesystem/azurefs.h
b/cpp/src/arrow/filesystem/azurefs.h
index 69f6295237..346dd349e9 100644
--- a/cpp/src/arrow/filesystem/azurefs.h
+++ b/cpp/src/arrow/filesystem/azurefs.h
@@ -110,6 +110,11 @@ struct ARROW_EXPORT AzureOptions {
Status ConfigureAccountKeyCredential(const std::string& account_name,
const std::string& account_key);
+ Status ConfigureClientSecretCredential(const std::string& account_name,
+ const std::string& tenant_id,
+ const std::string& client_id,
+ const std::string& client_secret);
+
bool Equals(const AzureOptions& other) const;
std::string AccountBlobUrl(const std::string& account_name) const;
diff --git a/cpp/src/arrow/filesystem/azurefs_test.cc
b/cpp/src/arrow/filesystem/azurefs_test.cc
index 3266c1bfda..62c5ef2232 100644
--- a/cpp/src/arrow/filesystem/azurefs_test.cc
+++ b/cpp/src/arrow/filesystem/azurefs_test.cc
@@ -271,6 +271,13 @@ class AzureHierarchicalNSEnv : public
AzureEnvImpl<AzureHierarchicalNSEnv> {
bool WithHierarchicalNamespace() const final { return true; }
};
+TEST(AzureFileSystem, InitializeFilesystemWithClientSecretCredential) {
+ AzureOptions options;
+ ARROW_EXPECT_OK(options.ConfigureClientSecretCredential(
+ "dummy-account-name", "tenant_id", "client_id", "client_secret"));
+ EXPECT_OK_AND_ASSIGN(auto fs, AzureFileSystem::Make(options));
+}
+
TEST(AzureFileSystem, InitializeFilesystemWithDefaultCredential) {
AzureOptions options;
ARROW_EXPECT_OK(options.ConfigureDefaultCredential("dummy-account-name"));