@@ -108,12 +108,14 @@ AzureObjectStorage::AzureObjectStorage(
108108 ClientPtr && client_,
109109 SettingsPtr && settings_,
110110 const String & object_namespace_,
111- const String & description_)
111+ const String & description_,
112+ AzureBlobStorage::AuthMethod auth_method_)
112113 : name(name_)
113114 , client(std::move(client_))
114115 , settings(std::move(settings_))
115116 , object_namespace(object_namespace_)
116117 , description(description_)
118+ , auth_method(auth_method_)
117119 , log(getLogger(" AzureObjectStorage" ))
118120{
119121}
@@ -154,6 +156,40 @@ ObjectStorageIteratorPtr AzureObjectStorage::iterate(const std::string & path_pr
154156 return std::make_shared<AzureIteratorAsync>(path_prefix, client_ptr, max_keys ? max_keys : settings_ptr->list_object_keys_size );
155157}
156158
159+ std::optional<std::string> AzureObjectStorage::getIdentityFingerprint () const
160+ {
161+ std::optional<std::string> fingerprint;
162+
163+ std::visit ([&fingerprint](const auto & auth) {
164+ using T = std::decay_t <decltype (auth)>;
165+
166+ if constexpr (std::is_same_v<T, AzureBlobStorage::ConnectionString>)
167+ {
168+ auto connection_string_parts = Azure::Storage::_internal::ParseConnectionString (auth);
169+ fingerprint = std::to_string (std::hash<std::string>()(connection_string_parts.AccountName ));
170+ }
171+ else if constexpr (std::is_same_v<T, std::shared_ptr<Azure::Storage::StorageSharedKeyCredential>>)
172+ {
173+ if (auth)
174+ {
175+ fingerprint = std::to_string (std::hash<std::string>()(auth->AccountName ));
176+ }
177+ }
178+ // / I am not sure what to do with the other auth methods, needs further investigation
179+ // else if constexpr (std::is_same_v<T, std::shared_ptr<Azure::Identity::WorkloadIdentityCredential>>) {
180+ // }
181+ // else if constexpr (std::is_same_v<T, std::shared_ptr<Azure::Identity::ManagedIdentityCredential>>) {
182+ // }
183+ }, auth_method);
184+
185+ if (!fingerprint)
186+ {
187+ return std::nullopt ;
188+ }
189+
190+ return getName () + fingerprint.value ();
191+ }
192+
157193void AzureObjectStorage::listObjects (const std::string & path, RelativePathsWithMetadata & children, size_t max_keys) const
158194{
159195 auto client_ptr = client.get ();
@@ -380,7 +416,7 @@ std::unique_ptr<IObjectStorage> AzureObjectStorage::cloneObjectStorage(
380416 };
381417
382418 auto new_client = AzureBlobStorage::getContainerClient (params, /* readonly=*/ true );
383- return std::make_unique<AzureObjectStorage>(name, std::move (new_client), std::move (new_settings), new_namespace, params.endpoint .getServiceEndpoint ());
419+ return std::make_unique<AzureObjectStorage>(name, std::move (new_client), std::move (new_settings), new_namespace, params.endpoint .getServiceEndpoint (), params. auth_method );
384420}
385421
386422}
0 commit comments